Questions tagged [nsnull]

The NSNull class defines a singleton object used to represent null values in collection objects (which don’t allow nil values).

82 questions
7
votes
6 answers

how to remove NULL values from NSMutableArray? ios

i have array of birthdates as array is getting filled from facebook so there are some friends whos birthdates are private so it contain NULL how to convert that array like empty string wherever there is null value the array is like below…
Prakash Desai
  • 168
  • 1
  • 9
6
votes
4 answers

Check if parsed json is NSNULL

I am parsing a JSON response and trying to check if one of my keys is null. How would I go about this? I have the following: var routingNumber = (dic.value(forKey: "result") as! NSDictionary).value(forKey: "routingNumber") as! String and this…
user2423476
  • 2,115
  • 8
  • 28
  • 40
5
votes
2 answers

NSJSONSerialization and NSNull

Occasionally I encounter JSON structure like "'data': null". NSJSONSerialization turns those into NSNull, which is, to be honest quite annoying. I understand the reason behind this - things like NSDictionary cannot contain nil value. That's fine,…
Peter Pei Guo
  • 7,770
  • 18
  • 35
  • 54
5
votes
4 answers

Removing nulls from a JSON structure recursively

I'm frequently finding the need to cache data structures created by NSJSONSerialization to disk and as -writeToFile fails if there are nulls, I need a fix that works when the structure is unknown. This works, and direct mutation is allowed as the…
TijuanaKez
  • 1,472
  • 3
  • 20
  • 28
3
votes
3 answers

NSInvalidArgumentException desired type = NSString; given type = __NSDictionaryM; Unacceptable type of value : property

Here i am setting some values using the NSManagedObject. First problem i got that when i am trying to assign the null value to the property it is giving error : desired type = NSString; given type =null. I am getting values from NSDictionary…
vicky
  • 253
  • 2
  • 14
3
votes
1 answer

How to set a core-data attibute to nil, in Swift?

Here is a working Swift function I have: func myColorFuntion (object:NSManagedObject) -> UIColor { if (object.valueForKey("bgColor") == nil) {return UIColor.yellowColor()} return…
Michel
  • 10,303
  • 17
  • 82
  • 179
3
votes
1 answer

isEqual: and isKindOfClass: - Which is faster?

For various reasons, in order to keep an array's indexes aligned with other things, I have [NSNull null] inside the array. Like this: NSArray *arr = @[obj1, obj2, obj3, [NSNull null], obj4]; There are two methods I'm considering using when…
rebello95
  • 8,486
  • 5
  • 44
  • 65
3
votes
1 answer

Is it kosher to use NSNull category trick in order to avoid [NSNull performSelector:...] problems?

In our project, we occasionally get our iPhone app to crash when there is something on the network returns JSON with nil in it. Of course, we do have a helper class, which takes care of problems like that. However, people are error-prone and do call…
mutable.me
  • 351
  • 2
  • 9
2
votes
0 answers

Exception thrown while executing UI block: [NSNull doubleValue]: unrecognized selector sent to instance 0x204329c00

I am trying to display icon relative to specific coordinates on a map, but I keep getting this error thrown, followed by: removedChildren count(0) was not what we expected (1) This won't allow the pin to show up on the map. Below is my code: const…
MK_Pierce
  • 916
  • 2
  • 10
  • 26
2
votes
2 answers

Crash cause of [NSNull objectForKey:] but I can't find where

I have a crash on my iPhone App, I have this error : [724:95876] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull objectForKey:]: unrecognized selector sent to instance 0x1b5970878' And that's all. I…
Mathieu Robert
  • 325
  • 1
  • 5
  • 17
2
votes
1 answer

Set NSNull() if the string is nil

When a user does facebook login in my app, some of the expected value such as dateOfBirth, email can be nil. I want to set the value of self.fbResponse.email to NSNull(), if it is nil. So that I can post the parameters to server. let…
Hem Poudyal
  • 321
  • 6
  • 16
2
votes
3 answers

How to check if (id) object is null in ios?

I have made a function to consume webservices , now I want to check if (id) object is null or not. What I am doing is here: -(void)callService:(NSString*)request param:(NSString*) parameters completion:(void (^)(NSArray *list, NSError…
MQ.
  • 365
  • 6
  • 28
2
votes
1 answer

how to check if NSMutableArray element is NSNull or AnyObject

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…
Chameleon
  • 1,608
  • 3
  • 21
  • 39
2
votes
2 answers

Weird error in UITableView NSInvalidArgumentException reason: [NSNull length], when it is not null

I am having a crush problem. This is the first thing that I couldn't find the solution online. Please help if you had same problem before. Thanks. Error message: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:…
ayalcin
  • 877
  • 1
  • 8
  • 16
2
votes
5 answers

Browsing an object's fields

In Objective C, I have an object e.g. Person with a lot of fields firstName, lastName, phoneNumber, address, city... and so on. These fields types are NSString and any of these could be nil. Now I want to concatenate my field values in another…
Arnaud
  • 7,259
  • 10
  • 50
  • 71