Results 1 to 2 of 2

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Error when trying to change .txt to array to .plist

  1. #1
    Default Error when trying to change .txt to array to .plist
    im trying to change a text file with per line information to a plist so i can read the array info for other things. the code is:

    NSString *File = [NSString stringWithContentsOfFile:@"/var/mobile/Example.txt"];
    NSArray *FileArray = [File componentsSeparatedByString:@"\n"];
    NSMutableDictionary *FileArray = [[NSMutableDictionary alloc] init];
    [FileArray setObject:itemsArray forKey:@"Saved"];
    [FileArray writeToFile:@"/var/mobile/Array.plist" atomically:YES];


    i keep getting errors like FileArray is already defined.
    Please Help!

  2. #2
    In these two lines:
    Code:
    NSArray *FileArray = [File componentsSeparatedByString:@"\n"];
    NSMutableDictionary *FileArray = [[NSMutableDictionary alloc] init];
    you are telling the compiler you want a variable named FileArray of type NSArray and a variable of type NSMutableDictionary named FileArray - one variable can't be both at once.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •