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
1
vote
1 answer
App crashes if Last Name in Contacts is empty for iOS 5 +
I am trying to retrieve contacts from address book & display it in table view with indexed list same as Contacts app in iOS. I am sorting contacts on LAST NAME. If last name is empty then my app crashes. Here is my code
-…

iOSAppDev
- 2,755
- 4
- 39
- 77
1
vote
1 answer
When if ever will a property of type NSString be [NSNull null]
I'm parsing some json to return a basic string token or error message.
- (void)callBackWithVerifyHttpResponse:(NSData *)response
{
SomeResult *result = [self.parser parseVerifyHttpResponseAndReturnResult:response];
if (result.token) {…

Toran Billups
- 27,111
- 40
- 155
- 268
0
votes
1 answer
JSON: NSString stringWithContentsOfURL... with null in stream, crashes
Environment: iOS 4.3+ using Xcode 4.3+
I'm always getting an iOS/Xcode crash when I implement the following string that returns data with nulls in it:
[NSString stringWithContentsOfURL:myURL encoding:NSUTF8StringEncoding error:&error];
NSDictionary…

Frederick C. Lee
- 9,019
- 17
- 64
- 105
0
votes
0 answers
NSInvalidArgumentException Unacceptable type of value for attribute: property; desired type = NSString; given type = NSNull; value =
Problem: when assigning the null value to a property it gives error: desired type = NSString; given type =null.
Recieving this value from NSDictionary *logBookClass = [json objectForKey:LOG_BOOK]; And when the value is null the app crashes giving…

Tarang Sharma
- 43
- 1
- 5
0
votes
1 answer
How to check for in Swift 5 and avoid 'NSInvalidArgumentException'?
I'm using Swift 5.
Why does an NSInvalidArgumentException occur when responseValues["CustomerID"] == ''?
Obviously the if responseValues["CustomerID"] is NSNull is not doing the trick. What check should be in place to avoid the…

Sam Luther
- 1,170
- 3
- 18
- 38
0
votes
1 answer
Swift does not retrieve Firebase values (returns values as NSNull)
I'm trying to pull values from my Firebase real-time database, but for whatever reason the values come back as NSNull. I was getting error 'Could not cast value of type 'NSNull' to 'NSNumber' on line 13 until I changed 'let count = ...' to an 'if…

iOS_Mtrx
- 3
- 2
0
votes
3 answers
Why does this null check fail?
I am using this simple code to check if an NSString object is null, but for some reason it fails
here is my simple check
NSString *imageUrl = [dict objectForKey:@"imageUrl"];
NSLog(@"Jonge: %@", imageUrl);
if(
Matt Douhan
- 2,053
- 1
- 21
- 40
0
votes
0 answers
terminating with uncaught exception of type NSException (objective C)
The program closes at Objective-c. Please help solve my problem.
Error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized
selector sent to instance 0x115289cf0'
enter image…

Mehmet can
- 11
- 2
0
votes
1 answer
How to know where is my app crashing, only with this log info?
I need to detect where is my app crashing, I tried debugging line by line, but suddenly, the debugger jumps from the "assembler code" (is that the proper name?) into the crash, so I can't tell you exactly what the offending code is.
I am doing text…

Josh
- 6,251
- 2
- 46
- 73
0
votes
4 answers
swift how can I check for NULL values coming from Json
I have a rest api and am getting all data via Json then putting it in a IOS TableView. My issue is that some data is being returned as NULL in Json
"vote_status":null
I am trying to get that NULL value in swift and change it to a string "0" but am…

Rome Torres
- 1,061
- 2
- 13
- 27
0
votes
2 answers
how to convert null string to null swift
I am new to Swift. I tried with this Swift link Detect a Null value in NSDictionaryNSDictionary, but I failed to do so.
Data:
"end_time" = ""
Here is my code:
if endTime["end_time"] is NSNull {
print("your session still available ")
…

cristan lika
- 415
- 1
- 7
- 22
0
votes
3 answers
I'm getting from the database dictionary in which there is one or more objects NSNull
I'm getting from the database dictionary in which there is one or more objects NSNull. In the future, I can not in any way to work with him as the app crash. I tried many ways to remove from the dictionary NSNull objects, method removeObjectForKey…

Sasha Tsvigun
- 311
- 5
- 15
0
votes
2 answers
NSNull returns instead of returning null
I'm using the following code to check if a NSNumber has nil value. So I'm converting the NSNumber to string and Im checking if its length is 0. If it is of zero, Im returning NSNull else Im returning the number itself.
-…
user6092898
0
votes
3 answers
IOS: Detecting NSNull from JSON Not Working
The following code designed to catch an NSNull in Json results is throwing an exception when the response is null.
NSDictionary *jsonResults = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
…

zztop
- 701
- 1
- 7
- 20
0
votes
2 answers
How to deal with NSNull in my data?
I am getting an [NSNull rangeOfCharacterFromSet:]: exception when attempting to display a label. The error reads
'NSInvalidArgumentException', reason: '-[NSNull length]:
Below is my code.
UILabel* spousename = [[UILabel alloc]…

Dave
- 873
- 2
- 15
- 27