• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Null result from NSArray objectAtIndex
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Null result from NSArray objectAtIndex


  • Subject: Null result from NSArray objectAtIndex
  • From: "A.Sleep" <email@hidden>
  • Date: Wed, 23 Mar 2005 16:55:11 -0500

I'm having an issue with this little app I'm porting/rewriting... The code is available for review @ http://www.asleep.net/hacking/ OSXPal_1.0-ALPHA.zip. The primary issue is in OSXPal.m in the changeDockIcon method.

This is a port of my app wmpal a Window Maker dockapp available @ the same site but hacking/wmpal/.

Users can choose a "pal" which will determine the appicon in the doc. Every X seconds (by timer) the appicon is changed to an icon in the group of 3 belonging to each of the "pals". I've got NSLog messages in the current OSXPal.m file and watching the application run one can see 3 of the 6 "pal" images work as expected, however the other 3 come up as (null) and I'm _very_ confused as to why.

If anyone could take the time to review this for me and point me in the right direction I'd be grateful. I'm starting to pull my hair out (and that doesn't feel very good since I shave my head).

Method from described OSXPal.h below:

- (void)changeDockIcon:(NSTimer *)timer
{
NSString *palImageSetting = [[NSUserDefaults standardUserDefaults] stringForKey:@"palImage"];


    NSLog(@"palImageSetting: %s", [palImageSetting cString]);

    if (!palImageSetting) {
        palImageSetting = @"Dino";
    }

NSString *icnsOneSuffix = @"1.icns";
NSString *icnsTwoSuffix = @"2.icns";
NSString *icnsThreeSuffix = @"3.icns";
NSMutableString *ImageOne = [NSMutableString stringWithFormat: @"%@ %@", palImageSetting, icnsOneSuffix];
NSMutableString *ImageTwo = [NSMutableString stringWithFormat: @"%@ %@", palImageSetting, icnsTwoSuffix];
NSMutableString *ImageThree = [NSMutableString stringWithFormat: @"%@ %@", palImageSetting, icnsThreeSuffix];
NSArray *palImages = [[NSArray alloc] initWithObjects:ImageOne,ImageTwo,ImageThree,nil];


    time_t t;
    int waitTime;

    srand(time(&t));
    waitTime = rand() % maxWait +1;

timer = [NSTimer scheduledTimerWithTimeInterval:waitTime target:self selector:@selector(changeDockIcon:) userInfo:nil repeats:NO];

    NSLog(@"Grabbing object at position %i.", position);

NSImage *palImage = [NSImage imageNamed:[palImages objectAtIndex:position]];

NSLog(@"Setting application icon to %s and setting timer for %i seconds...", [[palImage name] cString], waitTime);

    [NSApp setApplicationIconImage:palImage];

    if (position >= 2) {
        position = 0;
    }
    else {
        position++;
    }

}

---
A.Sleep - Jeraimee Hughes
Email: email@hidden
Cell: 954.854.3155

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Null result from NSArray objectAtIndex
      • From: Guy English <email@hidden>
    • Re: Null result from NSArray objectAtIndex
      • From: John Brownlow <email@hidden>
  • Prev by Date: Re: Case insensitive autocomplete
  • Next by Date: Re: Null result from NSArray objectAtIndex
  • Previous by thread: Random image problem solved, but...
  • Next by thread: Re: Null result from NSArray objectAtIndex
  • Index(es):
    • Date
    • Thread