NSString *tmpStr = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
xmlSms = [xmlSms stringByAppendingString:tmpStr];
NSLog(xmlSms);
I got code above but NSLog
doesn't show anything... Anybody know the problem??
NSString *tmpStr = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
xmlSms = [xmlSms stringByAppendingString:tmpStr];
NSLog(xmlSms);
I got code above but NSLog
doesn't show anything... Anybody know the problem??
In Cocoa, initialization functions ("constructors") often return nil
if they fail for some reason or another. The documentation for NSString
states:
Returns nil if the initialization fails for some reason (for example if data does not represent valid data for encoding).
Are you sure the NSData
object passed to the init function actually contains a UTF8-encoded string? If it doesn't, the returned object will be nil
.
nevermind... i figured out why. The problem is, when you want to use stringByAppendingString on a string, the string should have initial value.
Wrong example: NSString *str1; str1 = [str1 stringByAppendingString=@"test"]; Should be: NSString *str1 = @""; str1 = [str1 stringByAppendingString=@"test"];