However, if you need to set the properties or methods of the call after creating the object, using a temporary object can be a bit nicer than calling self.movie several times:
Movie *newMovie = [[[Movie alloc] initWithTitle:@"Iron Man" boxOfficeGross:[NSNumber numberWithFloat:650000000.00] summary:@"Smart guy makes cool armor" ] autorelease]; newMovie.rating = 4; [newMovie fetchImageFromServer]; self.movie = newMovie;
Personally, I do not use autorelease in this scenario, but this is more a style preference:
Movie *newMovie = [[Movie alloc] initWithTitle:@"Iron Man" boxOfficeGross:[NSNumber numberWithFloat:650000000.00] summary:@"Smart guy makes cool armor" ]; newMovie.rating = 4; [newMovie fetchImageFromServer]; self.movie = newMovie; [newMovie release];
source share