I have a method which runs this:
Track* track = [[Track alloc] init:[obj objectForKey:@"PersistentID"] :[obj objec开发者_高级运维tForKey:@"Name"] :[obj objectForKey:@"Artist"] :(NSInteger*)[obj objectForKey:@"Total Time"] :(NSInteger*)[obj objectForKey:@"Play Count"]];
[self setCurrentTrack:(Track*) track];
[track release];
Do I have to release track?
Yes. You are responsible for release'ing an object anytime you own the object. You own an object any time you send it an alloc, new, copy or retain message. Your currentTrack property should retain the track.
well, you don't HAVE to, but if you don't have to use it anymore then you should. also it's not necessary to have ":(Track*) track];" I personally prefer
[self setCurrentTrack:track];
because it's a more common practice.
精彩评论