English 中文(简体)
甲型六氯环己烷和甲型六氯环己烷中的甲型六氯环己烷吗?
原标题:Null different from false in booleans?

我有办法提出员额要求。 这项请求可能有x个参数,但没有一个是强制性的。 类型养蜂的参数(这些参数被作为具有“真实”或“变数”的体体(不是我的决定,而是APIC)。

这就是问题。 我的方法声明包含作为员额请求的一部分接受的所有参数。 问题是,如果毛豆参数真实、不真实或不存在,则请求回报不同。

我的手法是仿佛的。

-(void) createRequestWithID:(NSString *)id translate(NSNumber *)translate onlyLastVersions:(NSNumber *)onlyLastVersions

我的方法是另一个框架的一部分,将由其他开发商使用和要求。 这意味着,我无法控制这些参数,例如转化是一种ool(我把NSNumber用作包装)。

这里也是问题。 我需要能够确定这种方法是否被称作是真实的、虚假的或无真实的。 由于这些情况,我将要求翻译为“真实”,翻译为“真实”,或翻译不在请求中。

我需要一种办法,区分真实、虚假和零。

• 测试 g,试图找到一种不同的方法,我获得:

(gdb) p translateFALSE $5 = (NSNumber *) 0x0

(gdb) p translateNIL $6 = (NSNumber *) 0x0

(gdb) po translateFALSE Can t print the description of a NIL object.

(gdb) po translateNIL Can t print the description of a NIL object.

(gdb) po [translateFALSE class] Can t print the description of a NIL object.

(gdb) po [translateNIL class] Can t print the description of a NIL object.

因此,我看不到这样做的途径。

最佳回答
if( translate ) {
  if( [translate boolValue] ) {
    // translate is present and is set (YES)
  } else {
    // translate is present and is not set (NO)
  }
} else {
  // translate is nil / not present
}

如果你更喜欢一个三维分支:

if( [translate boolValue] ) {
  // translate is present and is set (YES)
} else if( translate ) {
  // translate is present and is not set (NO)
} else {
  // translate is nil / not present
}
问题回答

没有任何东西,例如乌民族军(或Nil)用于养蜂——全国人民军是一个点值。 净水量为零,但代表BOOL的NSN网不会为零。

如果你重新通过该物体的NSNumber。 你可以很容易区分物体或具有无价值。 (见你试图提取标值。)





相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...