I use this method to access my mysql database from Xcode:
NSString *URL = [NSString
stringWithFormat:@”http://test.test:8888/test/loadUserData.php?username=%@”,
userName];NSString *rawJSON = [[NSString alloc]
initWithContentsOfURL:[NSURL
URLWithString:URL]];const char *convert = [rawJSON
UTF8String]; NSString *responseString
= [NSString stringWithUTF8String:convert];if ([rawJSON length] == 0) {
[rawJSON release];}
SBJsonParser *parser = [[SBJsonParser
alloc] init];userInfo = [[parser
objectWithString:responseString
error:nil] copy]; SSN = [userInfo
objectAtIndex:0];[parser release];
return userInfo;
Everything works great. EXCEPT that I can’t compare strings in the result with normal nsstrings. If I say
if ([userinfo objectAtIndex:0) == @”Dan”)
{
..do something
}
Xcode never sees that it is the same value..
I don’t know if there is something wrong with the format (My database is UTF-8)
And how can I convert the result so xCode can compare the response with NSStrings?
Thanks!
==does not compare the value of strings, it just compares their addresses.Use
or something similar instead.