ios - Display data in other view controllers -
this question has answer here:
- passing data between view controllers 35 answers
in storyboard have set facebook login fetches users username , profile picture. have done in initial uiviewcontroller (aka loginviewcontroller).
what want able send data (the username , profile picture) other places. more specifically, want able to:
- display fetched profile picture in uiimageview in different uiviewcontroller
- display username in text field in different uiviewcontroller
if tell me how either code example or storyboard walkthrough appreciative.
save details retrieved in loginviewcontroller using nsuserdefaults. system provided convenient storage gives nsdictionary access. can retrieve details other controllers.
to save loginviewcontroller,
[[nsuserdefaults standarduserdefaults] setobject:@"user1" forkey:@"username"] ; [[nsuserdefaults standarduserdefaults] setobject:uiimagejpegrepresentation(image, 1.0) forkey:@"picture"] ; to retrieve view controller,
nsstring *username = [[nsuserdefaults standarduserdefaults] objectforkey:@"username"] ; uiimage *image = [uiimage imagewithdata:[[nsuserdefaults standarduserdefaults] objectforkey:@"picture"]] ;
Comments
Post a Comment