简体   繁体   中英

Objective C Passing Data

http://www.freeimagehosting.net/g2kbc

displaycontoller *show = [[displaycontroller alloc] initWithNibName:@"displaycontroller" bundle:[NSBundle mainBundle]];

Contacts *contacts = [arr objectAtIndex:indexPath.row];

show.context = context;
show.contacts = contacts;

In the display view controller everything is ok, and again I am passing the same data to the edit view controller

editcontoller *edit = [[editcontroller alloc] initWithNibName:@"editcontroller" bundle:[NSBundle mainBundle]];


edit.context = context;
edit.contacts = contacts;

In the edit view controller I get empty cells If I print the data I get (null)

If I skip the detail view controller, from table to the edit view controller everything works great... But when I do from table view to display to edit view, I get zeros(nill).

In the display, insert these two logs before the two assignments and observe the log.

NSLog(@"context: %@", context);   // see any valid data
NSLog(@"contacts: %@", contacts);  // see any valid data

edit.context = context;
edit.contacts = contacts;

Instead of edit.context = context try

editcontoller *edit = [[editcontroller alloc] initWithNibName:@"editcontroller" bundle:[NSBundle mainBundle]];


edit.context = self.context;
edit.contacts = self.contacts;

Maybe there is some trouble with instance variables in your controller.

And log the variables there, to see, what's happening.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM