objective c - iOS Updating Property of an Object -


i'm new ios dev , question i'd appreciate guidance on.

i have viewcontroller has property want regularly replace:

@property (strong, nonatomic) iboutlet uiimageview *image; 

now in class update property, first alloc , init viewcontroller update property accordingly. when come replace image ever uses first image. if instantiate viewcontroller alloc init works ok.

so question correct/best practice way update, creating new instances of viewcontroller - memory efficiency wise best practice?

thanks.

it sounds want change image, rather replacing entire view controller.

can show code changing image? also, please specify if want change image view or image inside it. (the image view displays actual image on screen. suggest name property imageview, avoid confusion.)

here 2 examples. i'm assuming there variable 'theviewcontroller' holds reference view controller.

replacing image view:

// create new image view new image inside theviewcontroller.image = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"img1"]]; 

replacing image:

// put new image existing image view theviewcontroller.image.image = [uiimage imagenamed:@"img1"]; 

the last example demonstrates why property name imageview preferably image: now, looks changing 'the image on image'. actually, changing image on imageview.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -