Прежде всего, вы должны прочитать некоторые основы программирования IOS. И,
NSMutableDictionary *temp = [[NSMutableDictionary alloc]init];
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
temp = [responseString JSONValue]; //----> this line is wrong
потому, temp
указатель указывает на вновь созданный NSMutableDictionary
объекта, вы переназначение его на другой объект, возвращаемый JSONValue
методом, который autorelease
объект, и вы не имеете его, таким образом, может» t release
it. Некоторые лучшие способы достижения хотят, чтобы вы хотели бы:
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
NSMutableDictionary *temp = [responseString JSONValue];
NSLog(@"webdata is %@",temp);
NSLog(@"inside usersignup success");
[[NSNotificationCenter defaultCenter] postNotificationName:CNotifySignupSucess object:temp];
//NO RELEASING the AUTORELEASE OBJECT!!!!
ИЛИ:
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
NSMutableDictionary *temp = [[NSMutableDictionary alloc]initWithDictionary:[responseString JSONValue]];
NSLog(@"webdata is %@",temp);
NSLog(@"inside usersignup success");
[[NSNotificationCenter defaultCenter] postNotificationName:CNotifySignupSucess object:temp];
[temp release];
ИЛИ:
NSMutableDictionary *temp = [[NSMutableDictionary alloc]init];
NSString *responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];
[temp addEntriesFromDictionary:[responseString JSONValue]];
NSLog(@"webdata is %@",temp);
NSLog(@"inside usersignup success");
[[NSNotificationCenter defaultCenter] postNotificationName:CNotifySignupSucess object:temp];
[temp release];
В последних 2-х случаях я, учитывая, что JSONValue
метод возвращает NSDictionary
, Goog Luck!
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (signupsucessreceived :) имя: объект CNotifySignupSucess: nil]; – jpd
NSMutableDictionary * dict = notification.object; if ([[dict objectForKey: @ "Success"] isEqualToString: @ "1"]) { appDelegate.islogin = TRUE; self.title = nil; [appDelegate.userinfo setObject: [dict objectForKey: @ "user_id"] forKey: @ "userid"]; NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; NSString * strtemp = [NSString stringWithFormat: @ "% @", [dict objectForKey: @ "user_id"]]; [defaults setObject: strtemp forKey: @ "userid"]; – jpd
Роб, я пытаюсь это сделать – jpd