NSString function <p>I get a null return when i try out my NSString function.</p> <pre><code>//Track.m static NSString* trackUrl; //static NSString* getTrackNumberUrl; @implementation Track - (NSString*)trackUrl { return @"http://site.com/?a="; } - (NSString*)setTrackNumberUrl:(NSString*)trackNumberUrl { if (trackUrl != trackNumberUrl) { return [trackUrl stringByAppendingFormat:trackNumberUrl]; } return @"Error no trackNumber"; } - (NSString*)getTrackNumberUrl:(NSString*)trackNumber { return [[[self alloc] setTrackNumberUrl:trackNumber] autorelease]; } @end </code></pre> <p>MainView.m, just to show the return answer in NSlog</p> <pre><code>- (NSString *) trackNumber{ return [track getTrackNumberUrl:@"86147224549XX"]; } - (void)drawRect:(CGRect)rect { NSLog(trackNumber); } </code></pre> <p>I get a null return answer? Have i miss something? Thanks.</p> <p>Edit some in Track.m</p> <pre><code>- (NSString*)setTrackNumberUrl:(NSString*)trackNumberUrl { if (trackUrl != trackNumberUrl) { return [trackUrl stringByAppendingString:trackNumberUrl]; } return @"Error no trackNumber"; } - (NSString*)getTrackNumberUrl:(NSString*)trackNumber { return [[[Track alloc] setTrackNumberUrl:trackNumber] init]; } </code></pre> <p>This is how it should work.</p> <p>getTrackNumberUrl --> setTrackNumberUrl --> trackUrl (return) --> setTrackNumberUrl + trackNumber --> getTrackNumberUrl (trackNumberUrl = trackUrl + trackNumber)</p> <hr> <p>I have this code to set reference to Track</p> <pre><code>@class Track; @interface MainView : UIView { Track *track; } @property (nonatomic, retain) IBOutlet Track *track; </code></pre> <p>Well if don't should use self alloc, what should i use?</p>