Вопрос

I am new to iPhone development and Three20 framework. I created a simple login controller which returns user details as json response from PHP. i need to store json response into an object or something which can be shared on other views, for example i want to show received user details on profile view controller.

- (void)requestDidFinishLoad:(TTURLRequest *)request {
_loading = NO;
_loaded = YES;

TTURLDataResponse *response = request.response;

NSString *responseBody = [[NSString alloc]initWithData:response.data encoding:NSUTF8StringEncoding];

SBJSON *jsonParser = [[[SBJSON alloc] init] autorelease];

loggedUser = (NSDictionary *) [jsonParser objectWithString:responseBody error:nil];
NSLog(@"%@",loggedUser);

[super requestDidFinishLoad:request]; 

}

Rightnow loggedUser is a NSDictionary. I want to access loggedUser in profileViewController.m

please guide. Thanks

Это было полезно?

Решение

You should move in the direction of creating a Model four your app.

One easy way for that is having your Model as a singleton class that you can the access from everywhere in your code.

Have a look at this S.O. thread for a couple of variant implementations.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top