Example:
What I should have:
2011-11-27 18:55:12.816 SongDemo[5439:707] #1: Artist: Derek and the Dominos Title: Layla
2011-11-27 18:55:12.819 SongDemo[5439:707] #2: Artist: Simon and Garfunkel Title: Bridge Over Troubled Water
2011-11-27 18:55:12.820 SongDemo[5439:707] #3: Artist: The Beatles Title: Let It Be
2011-11-27 18:55:12.821 SongDemo[5439:707] #4: Artist: Elton John Title: Your Song
2011-11-27 18:55:12.822 SongDemo[5439:707] #5: Artist: James Brown Title: Get Up (I Feel Like Being A) Sex Machine
2011-11-27 18:55:12.823 SongDemo[5439:707] #6: Artist: The Kinks Title: Lola
2011-11-27 18:55:12.823 SongDemo[5439:707] #7: Artist: Creedence Clearwater Revival Title: Who'll Stop the Rain
2011-11-27 18:55:12.824 SongDemo[5439:707] #8: Artist: James Taylor Title: Fire and Rain
2011-11-27 18:55:12.825 SongDemo[5439:707] #9: Artist: Black Sabbath Title: Paranoid
2011-11-27 18:55:12.826 SongDemo[5439:707] #10: Artist: Free Title: All Right Now
What I get:
2011-11-27 18:56:07.307 SongDemo[5455:707] #1: Artist: Free Title: All Right Now
2011-11-27 18:56:07.313 SongDemo[5455:707] #2: Artist: Free Title: All Right Now
2011-11-27 18:56:07.315 SongDemo[5455:707] #3: Artist: Free Title: All Right Now
2011-11-27 18:56:07.316 SongDemo[5455:707] #4: Artist: Free Title: All Right Now
2011-11-27 18:56:07.317 SongDemo[5455:707] #5: Artist: Free Title: All Right Now
2011-11-27 18:56:07.317 SongDemo[5455:707] #6: Artist: Free Title: All Right Now
2011-11-27 18:56:07.318 SongDemo[5455:707] #7: Artist: Free Title: All Right Now
2011-11-27 18:56:07.319 SongDemo[5455:707] #8: Artist: Free Title: All Right Now
2011-11-27 18:56:07.321 SongDemo[5455:707] #9: Artist: Free Title: All Right Now
2011-11-27 18:56:07.323 SongDemo[5455:707] #10: Artist: Free Title: All Right Now
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Song *mySong = [[Song alloc] init];
NSMutableArray *songArray = [[NSMutableArray alloc]init];
NSArray *songArtist = [NSArray arrayWithObjects:@"Derek and the Dominos", @"Simon and Garfunkel",@"The Beatles",@"Elton John",@"James Brown",@"The Kinks",@"Creedence Clearwater Revival",@"James Taylor",@"Black Sabbath",@"Free", nil];
NSArray *songName = [NSArray arrayWithObjects:@"Layla",@"Bridge Over Troubled Water",@"Let It Be",@"Your Song",@"Get Up (I Feel Like Being A) Sex Machine",@"Lola",@"Who'll Stop the Rain",@"Fire and Rain",@"Paranoid",@"All Right Now", nil];
for (int x=0; x<10; x++) {
mySong.name = [songArtist objectAtIndex:x];
mySong.title = [songName objectAtIndex:x];
[songArray addObject:mySong];
//NSLog(@"#%i: Artist: %@ Title: %@",x+1, [[songArray objectAtIndex:x]name], [[songArray objectAtIndex:x]title]);
}
for (int x=0; x<10; x++) {
NSLog(@"#%i: Artist: %@ Title: %@",x+1, [[songArray objectAtIndex:x]name], [[songArray objectAtIndex:x]title]);
}
[pool drain];
return 0;
}
#import <Foundation/Foundation.h>
@interface Song : NSObject
{
NSString *name;
NSString *title;
}
@property(nonatomic, retain) NSString *name, *title;
@end
#import "Song.h" @implementation Song @synthesize name, title; @end

New Topic/Question
Reply



MultiQuote




|