Results 1 to 6 of 6
  1. #1
    NSDictionary doesn't work
    Code:
    [[NSBundle mainBundle] infoDictionary];
        NSString *cv = [[NSBundle mainBundle] pathForResource:@"Pezani Settings" ofType:@"plist"];
        NSDictionary *infocv = [NSDictionary dictionaryWithContentsOfFile:cv];
        NSString *Downloadcv = [infocv objectForKey:@"Word"];
     
     
     
    NSString *testWord = [NSString stringWithFormat:@"Test"];
       
        if ([testWord isEqualToString: Downloadcv]) {
           
        }
        else {
            [self performSelector:@selector(PezaniCheckInternet) withObject:@"" afterDelay:0.0];
           
        }
    Last edited by Raz0rEdge; 03-22-2015 at 11:20 AM. Reason: Code'ify

  2. #2
    NSDictionary doesn't work
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    12,329
    Rep Power
    24
    Can you explain what you are trying to do and why you think it isn't working? What do you have in the plist file?
    --
    Regards
    ...Ashwin


  3. #3
    In the plist file there is a string.

    Even if the word in the plist file is the same as in the code ("Test"),
    it will still do the action.

    The code needs to check if the word is the same as in the plist file, if it isn't the same, it should do the action. But now it always does the action.

  4. #4
    NSDictionary doesn't work
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    12,329
    Rep Power
    24
    So you want the empty IF block to run as opposed to the ELSE block?

    Debug the application and ensure that downloadcv does indeed contain the string "Test". You can very easily trace this code in XCode to see whats going on. With the debugger running you'll quickly see the problem..
    --
    Regards
    ...Ashwin


  5. #5
    It says Downloadcv NSString * nil 0x0000000000000000

  6. #6
    NSDictionary doesn't work
    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    200
    Rep Power
    9
    If your Downloadcv variable is equal to nil, then your code is working correctly.
    As the if condition has not been met.

    If your expecting your Downloadcv variable to be something other than nil, then check the key exists in the Dictionary.

    Regards Mark

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. NSDictionary doesn't work
    By TikaSoftware in forum macOS - Apps and Games
    Replies: 0
    Last Post: 03-22-2015, 11:17 AM
  2. VPN by iPhone work but at MacBook doesn't work! why ?
    By Jingol in forum Internet, Networking, and Wireless
    Replies: 3
    Last Post: 09-11-2013, 02:07 PM
  3. About the questions of NSDictionary
    By copperybean in forum iOS Development
    Replies: 2
    Last Post: 05-30-2012, 08:59 PM
  4. NSDictionary iteration
    By khaleed in forum iOS Development
    Replies: 1
    Last Post: 08-26-2011, 10:42 PM
  5. XCode (again) NSDictionary woes...
    By Raconteur in forum macOS - Development and Darwin
    Replies: 1
    Last Post: 06-10-2010, 04:14 PM

Posting Permissions

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