I created an AP list with a few words now I try to display a random word from that plast.
This is my code
NSArray * randomAddons = [NSArray arrayWithContentsOfFile: @ "wordEng.plist"]; Int randomIndex = arc4random ()% [randomAddons count]; MainTextController.text = [User Name 2 StringBapping string: [RandomAdson ObjectAttendIndex: Random Indax]]; This accidents and when I change the% [random invisible number]; % 3; It crashes, but I do not know how it can code correctly Can someone help me?
Thanks
Edit: The file I wrote was a problem in the plist file that was edited according to the jackjr300, below See the comments given. Still, I have been left with accidents, which I have from the beginning, the accident says:
Array: ((SSOM, Selsal, Donalden) 2012-07-10 03:41: 11.048 SpinningInternet [15 9bb 0 3] - [___ NSCFRA Length]: Unknown selector sent example 0xcfcfdd0 for example, 2012-07-10 03: 41: 11.048 SpinningInternational [15 9 1: 1bb 0] Without exception Epping Episode 'NSINIDADErgement Exception' due to 'FIS', Reason: '- [__Nscfire Nbai]: unrecognized selector sent to instance 0xcfcfdd0 '** * First place the call stack: (0x1b04022 0x1ee0cd6 0x1b05cbd 0x1a6aed0 0x1a6acb2 0x1468bd9 0x115dc3 0x3de995 0x979ed9 0x981725 0x8ea4ab 0x9837c6 0x8c9885 0x2166330 0x2168509 0x1a3b803 0x1a3ad84 0x1a3ac9b 0x26287d8 0x262888a 0xb3d626 0x29e2 0x1 0x2955) an exception ( Lldb) PRI files, PDF files, PDF files, PDF files, PDF files, PDF files, an array, its a dictionary should be :) / code (perception, Key words stored for keyForArray The array is:
(The correct implementation depends on the entires in the dictionary - how the rows are added to the plist file) <
NSDictionary * Random EntriesDictionary = [NSDictionary Dictionary] File with: [[NSBundle main bundle] pathForResource: @ "wordsENG" type: @ "plist"]]; NSUInteger dictionary field = [randomEntriesDictionary count]; If (zero! = Dictionary) {NSArray * randomWords = [randomEntriesDictionary objectForKey: keyForArray]; NSUInteger randomIndex = arc4Random% glossary; NSString * Random word = [random word item endindex: random index]; } Else {// Check if the file exists and is not empty? // Is it plist format? ... need)
Comments
Post a Comment