nsnull

Testing equality to NSNull

瘦欲@ 提交于 2020-01-23 04:32:05
问题 Below is a code block, that is supposed to test to see if a dictionary is null, and if it isn't, pull out the correct object. However, for some reason, despite the fact that the if check fails, the code still executes. Is there some quirk with how NSNull works that I don't understand, or is this an Apple bug? if (svcUser && !(svcUser == (id)[NSNull null])) { return [svcUser objectForKey:@"access_level"]; } Console response: (lldb) print svcUser && !(svcUser == (id)[NSNull null]) (bool) $0 =

[NSNull length]: unrecognized selector sent to instance 0x43fe068

被刻印的时光 ゝ 提交于 2020-01-11 11:30:08
问题 I am not exactly sure where this is coming from. I have a breakpoint on exceptions set but it does not show me what is really happening: libobjc.A.dylib`objc_exception_throw: 0x40308b9: pushl %ebp 0x40308ba: movl %esp, %ebp 0x40308bc: pushl %ebx 0x40308bd: pushl %edi 0x40308be: pushl %esi 0x40308bf: subl $0x7ec, %esp 0x40308c5: calll 0x40308ca ; objc_exception_throw + 17 0x40308ca: popl %ebx 0x40308cb: movl $0x10, (%esp) 0x40308d2: calll 0x4043698 ; symbol stub for: __cxa_allocate_exception

iphone - [NSNull getCharacters:]:

三世轮回 提交于 2020-01-07 03:10:53
问题 I got the above in an error message. [NSNull getCharacters:]: I cannot find it in the documentation. Can someone explain to me what it means? Many thanks. Edit: This is a different one than the question than the one linked to which is about the use of NSNull getCharacters. This one just asks what it means. 回答1: Straight from Apple documentation: "The NSNull class defines a singleton object used to represent null values in collection objects (which don’t allow nil values)." From here on, it's

-[NSNull length]: unrecognized selector sent to instance

99封情书 提交于 2019-12-25 18:36:10
问题 How to find where exactly did -[NSNull length]: unrecognized selector sent to instance happen i mean the line number. 回答1: Try putting a All Exception Breakpoint by: 1) Opening the left hand side panel (project navigator) 2) Click on the Breakpoints tab in the project navigator (it's the small icon next to the speech bubble) 3) Click the "+" sign on the bottom left of Xcode and choose Add Exception Breakpoint. It should default to All Exception. 4) Run your program again and try to make it

NSNull handling for NSManagedObject properties values

余生颓废 提交于 2019-12-20 08:37:35
问题 I'm setting values for properties of my NSManagedObject , these values are coming from a NSDictionary properly serialized from a JSON file. My problem is, that, when some value is [NSNull null] , I can't assign directly to the property: fight.winnerID = [dict objectForKey:@"winner"]; this throws a NSInvalidArgumentException "winnerID"; desired type = NSString; given type = NSNull; value = <null>; I could easily check the value for [NSNull null] and assign nil instead: fight.winnerID = [dict

How can I check if an object in an NSArray is NSNull?

≡放荡痞女 提交于 2019-12-18 10:25:09
问题 I am getting an array with null value. Please check the structure of my array below: ( "< null>" ) When I'm trying to access index 0 its crashing because of -[NSNull isEqualToString:]: unrecognized selector sent to instance 0x389cea70 Currently its crashing because of that array with a crash log: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull isEqualToString:]: unrecognized selector sent to instance 0x389cea70' *** First throw call stack:

What's the difference between [NSNull null] and nil?

…衆ロ難τιáo~ 提交于 2019-12-17 07:17:10
问题 Here's a context where I have seen that: NSMutableArray *controllers = [[NSMutableArray alloc] init]; for (unsigned i = 0; i < kNumberOfPages; i++) { [controllers addObject:[NSNull null]]; } why not nil in that place? 回答1: Directly from Apple: The NSNull class defines a singleton object you use to represent null values in situations where nil is prohibited as a value (typically in a collection object such as an array or a dictionary). So in your example, that's exactly what's happening, the

Assign NSNull Object to NSString

依然范特西╮ 提交于 2019-12-11 16:12:12
问题 I'm writing an iOS App where i need to get data from a SQL-Database over mobile Services from Azure. After downloading the data I get a NSDictionary with all attributes from the SQL-Table. If an attribute is empty, the value is NSNull . Is there a way to pass NSNull to NSString without an IF-Statement (I don't want to have 20 if statements..)? 回答1: I wrote a category just for dealing with this issue. I used it with Core Data but it should help you, too. @interface NSDictionary (Extensions) -

how to check if NSMutableArray element is NSNull or AnyObject

杀马特。学长 韩版系。学妹 提交于 2019-12-07 19:07:46
问题 I have a PersonsArray: NSMutableArray = [NSNull, NSNull, NSNUll, NSNull, NSNull, NSNUll, NSNull] . I needed seven slots that I then can fill with an Entity CoreData entry as AnyObject. I need to do a for in loop on this NSMutableArray... If the index slot is NSNull I want to pass to next index slot, if index slot is filled with my Object I want to execute code on this Object. example PersonsArray: NSMutableArray = [ NSNull, NSNull, NSNull, "<iswift.Person: 0x7f93d95d6ce0> (entity: Person; id:

how to check if NSMutableArray element is NSNull or AnyObject

霸气de小男生 提交于 2019-12-06 08:24:24
I have a PersonsArray: NSMutableArray = [NSNull, NSNull, NSNUll, NSNull, NSNull, NSNUll, NSNull] . I needed seven slots that I then can fill with an Entity CoreData entry as AnyObject. I need to do a for in loop on this NSMutableArray... If the index slot is NSNull I want to pass to next index slot, if index slot is filled with my Object I want to execute code on this Object. example PersonsArray: NSMutableArray = [ NSNull, NSNull, NSNull, "<iswift.Person: 0x7f93d95d6ce0> (entity: Person; id: 0xd000000000080000 <x-coredata://8DD0B78C-C624-4808-9231-1CB419EF8B50/Person/p2> ; data: {\n image =