基本的に私がやりたいことはこれです:1。URLから.plistを取得します2.plistファイルからNSMutableArrayに配列を置きます3.NSMutableArrayの各文字列をループし、それらを複数のNSMutableArrayにソートします
私はすでに1と2を実行しており、NSMutableArrayを使用できます。したがって、NSArrayからの文字列は次のようになります。
Looper|September 28th, 2012|http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4?TestLink|http://ia.media-imdb.com/images/M/MV5BMTM5NTkwMzI2MF5BMl5BanBnXkFtZTcwMTc5MjQ2Nw@@._V1._SY317_.jpg
これは映画の予告編アプリなので、私がやりたいのは、この文字列(およびNSMutabeArrayで同様にフォーマットされた他のすべての文字列)を4つの異なるNSMutableArrayに並べ替え、「|」で分割することです。componentsSeperatedByStringを使用します。これは私がこれまでに持っているものですが、「titleArray」をログに記録すると、配列の最初のタイトルしか表示されません。
NSInteger count = [newTrailers count];
for (int i = 0; i < count; i++) {
NSString* body = [newTrailers objectAtIndex:i];
NSArray *splits = [NSArray arrayWithObjects:body, nil];
NSMutableArray* titleArray = [[NSMutableArray alloc] init];
NSMutableArray* descriptionArray = [[NSMutableArray alloc] init];
NSMutableArray* linkArray = [[NSMutableArray alloc] init];
NSMutableArray* posterArray = [[NSMutableArray alloc] init];
for (NSString* item in splits)
{
NSArray* parts = [item componentsSeparatedByString: @"|"];
if ([parts count] == 4)
{
[titleArray addObject: [parts objectAtIndex: 0]];
[descriptionArray addObject: [parts objectAtIndex: 1]];
[linkArray addObject: [parts objectAtIndex: 2]];
[posterArray addObject: [parts objectAtIndex: 3]];
}
}
NSLog(@"Title Arrray: %@", titleArray);
}
助けてくれてありがとう、そして私はforループとintに慣れていないので、気楽にやってください!