The NSNull class defines a singleton object used to represent null values in collection objects (which don’t allow nil values).
Questions tagged [nsnull]
82 questions
2
votes
1 answer
Why doesn't NSNull behave like nil for unimplemented methods?
As per my understanding, NSNull exists as a replacement of nil in situations where an object is explicitly required, such in NSArray and NSDictionary collections.
One of the good parts of nil's behavior is that many verbose null checks can be…

Gabriele Petronella
- 106,943
- 21
- 217
- 235
1
vote
2 answers
touchJSON gives NSInvalidException NSNull isEqualtoString:
Hello I am new to Cocoa Development, and I'm trying to figure out what I did wrong. I followed a (tutorial) that uses touchJSON to fill a tableView with a mySQL database in Xcode. When I run the application everything is working fine, but when I…

Henri Blancke
- 25
- 1
- 5
1
vote
1 answer
How to get firebase child snapshot value back to work?
var test = String()
func fetchUser() {
let currentUserUid = Auth.auth().currentUser?.uid
Database.database().reference().child("users").child(currentUserUid!).child("test").observeSingleEvent(of: .value) { (snapshot) in
self.test =…
user10536150
1
vote
1 answer
Sending a `Null` value for parameter with Alamofire
I have updated to Swift3 and the latest Alamofire '~> 4.0'
When I try and make my parameters I now get instead of null for settings that I do not have set. Which conflicts with my backend.
Is there a way to send null?
When I set the value…

Dan Leonard
- 3,325
- 1
- 20
- 32
1
vote
4 answers
IOS: How to check json object is not null
I am getting an error with the following code when some json is null even though I am trying to check that first:
Edit: Preceding Code:
NSData* data = [NSData dataWithContentsOfURL: kItemsURL];
//previous line grabed data from api.
…

zztop
- 701
- 1
- 7
- 20
1
vote
1 answer
Variable is null when cast
I have a variable content from a NSArray : let content = application["content"]!
When I print content, I have a String :
print(content) -> My content
But when I want to cast my variable to String : let content = application["content"]! as! String
I…

BSK-Team
- 1,750
- 1
- 19
- 37
1
vote
1 answer
Null string crashes Swift conditional
I have a String property as part of a custom object. When I try to access the String on the custom object (when it's Null), the program crashes.
I can tell that the string is of type NSNull by printing out the custom object.
Every time I try
if…

cph2117
- 2,651
- 1
- 28
- 41
1
vote
2 answers
Remove NSNull values in a KVC generated NSMutableArray
Here's a little test:
NSDictionary * test = @ { @"centers" : @[
@{ @"id":@"12345", @"favorite":@NO },
@{ @"id":@"2345", @"favorite":@NO },
…

Zaphod
- 6,758
- 3
- 40
- 60
1
vote
2 answers
realm crash when NSData property is nil
I have a Realm class defined with "image" property of type NSData. I have set the default value for "image" in +defaultPropertyValues method's NSDictionary return value as
@"image":[NSNull null]. This is to indicate no image value has been…

everestman
- 143
- 1
- 9
1
vote
1 answer
Making NSNull conform to NilLiteralConvertible
I'm trying to make NSNull conform to NilLiteralConvertible, but I'm running into an enormous amount of frustration:
extension NSNull : NilLiteralConvertible{
required convenience init(nilLiteral: ()){
self.init()
}
}
First of all,…

cfischer
- 24,452
- 37
- 131
- 214
1
vote
1 answer
[NSNull length]: unrecognized selector sent to instance 0x43fe068
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: …

Slee
- 27,498
- 52
- 145
- 243
1
vote
1 answer
Adding NSDictionary keys with null values efficiently in ios5
I'm trying to add some values with keys in my dictionary for posting request to server. I have no issues on ios7 but having issue while creating dictionary in ios5, when a null value enters it doesnt insert that key or thereafter in the dictionary.…

Francis F
- 3,157
- 3
- 41
- 79
1
vote
1 answer
How to error check for a `null` object by the `json` interpreter in iOS
update: I think the error is coming from a missing key in the data feed and not a key with a null value.
I've been running into a null object by the json interpreter and thought this code would error check and avoid the crash. It's not working…

user2588945
- 1,681
- 6
- 25
- 38
1
vote
2 answers
Objective C NSPredicate predicateWithBlock removing nil/null values
I am trying to populate an array by taking an existing array and removing nil values from it. The array was populated from a the JSON response of an http call. Sometimes the array has a null value at the end, and the easiest way to remove that value…

Matt Wolfe
- 8,924
- 8
- 60
- 77
1
vote
4 answers
NSMutableDictionary and [NSNull null] values
Ok. I've searched and searched to no avail and I keep beating my head over this.
I'm trying to determine if a UITextField has a blank value, and if so send a null value up to the server, rather than just a blank string.
The following…

Adam Tootle
- 519
- 1
- 6
- 11