正確にはオブジェクトの配列(240オブジェクト)があります。すべてのオブジェクトには「round」というプロパティがあります。round== xの場合にオブジェクトを格納できる2番目の配列が必要です。
xは私が決めた数です。
-(void) parseXMLFixtures
{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"somethinggoeshereiwthanapikey"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *xmlString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSDictionary *xml = [NSDictionary dictionaryWithXMLString:xmlString];
NSMutableArray *items = [xml objectForKey:@"Match"];
NSMutableArray *newFixtureObjectArray = [[NSMutableArray alloc] init];
for (NSDictionary *dict in items) {
FixturesObject *myFixtures = [FixturesObject fixtureFromXMLDictionary:dict];
[newFixtureObjectArray addObject:myFixtures];
}
NSNull *nullValue = [NSNull null];
[newFixtureObjectArray insertObject:nullValue atIndex:0];
[newFixtureObjectArray insertObject:nullValue atIndex:1];
[self setTableDataFixtures:newFixtureObjectArray];
}
誰かが私がこれを達成する方法を知っていますか?
//////
NSNumber *myRound = [NSNumber numberWithInt:11];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"round = %@", myRound];
NSArray *filteredArray = [_roundParser filteredArrayUsingPredicate:predicate];
NSLog(@" roundParser %@", filteredArray);
2014-02-13 01:00:18.383 [6864:70b] roundParser (
)
2014-02-13 01:00:18.394 [6864:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101940795 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001016a3991 objc_exception_throw + 43
2 CoreFoundation 0x00000001018f902f -[__NSArrayI objectAtIndex:] + 175
3 Sagres Companion 0x0000000100019ddf -[FixturesController tableView:cellForRowAtIndexPath:] + 175
これを試して、
int num = 11;
NSString *yourX = [NSString stringWithFormat:@"%d", num];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"round = %@", yourX];
NSArray *filteredArray = [objectArray filteredArrayUsingPredicate:predicate];
yourXはNSString
あなたが見つける必要がある数です。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加