Array
vocabwords.txt - Файл в формате словаря из массивов строкNSArray *wordsCountriesEU = [[NSMutableArray alloc] initWithObjects:@"Spanish",@"Germany",@"Italy",nil]; NSArray *wordsCountriesAS = [[NSMutableArray alloc] initWithObjects:@"Iran",@"Oman",@"Livan",nil]; NSMutableDictionary *words = [[NSMutableDictionary dictionaryWithObjectsAndKeys: wordsCountriesEU, @"Europ", wordsCountriesAS, @"Asian", nil], retain]; [wordsCountriesEU release]; [wordsCountriesAS release]; NSArray *wordsInSection = [words objectForKey:@"Asian"]; int nCount = wordsInSection.count; [words release];
URL
NSURL *wordsUrl = [NSURL URLWithString:@"http://cs193p.stanford.edu/vocabwords.txt"]; NSMutableDictionary words = [[NSMutableDictionary dictionaryWithContentsOfURL:wordsUrl], retain]; NSArray *wordsInSection = [words objectForKey:@"Asian"]; int nCount = wordsInSection.count; [words release];
Комментариев нет:
Отправить комментарий