• 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
pb with nsmutablearray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pb with nsmutablearray


  • Subject: pb with nsmutablearray
  • From: "julien ricard" <email@hidden>
  • Date: Fri, 25 May 2007 15:06:13 +0200

hi,

I have an NSMutableArray of Track objects. After adding an instance of
Track to my array, displaying the location of the track works ok when
I get it directly from the Track object:

NSLog([track location]);

but it doesn't even compile when I get it from the array (error:
incompatible type for argument 1 of 'NSLog'):

NSLog([[trackList objectAtIndex:0] location]);

My main and Track.h are shown below. Anybody could help?

thanks
Julien


*******************main.m***********************

int main(int argc, char *argv[])
{

   NSMutableArray *trackList = [[NSMutableArray alloc]
initWithCapacity:nTrack];

   Track *track=[[Track alloc] init];
   [track setLocation:@"track name"];

   [trackList addObject:track];

   NSLog([track location]);
   NSLog([[trackList objectAtIndex:0] location]);

   [trackList release];


return NSApplicationMain(argc, (const char **) argv); }

*******************************************************


***********************Track.h**************************** @interface Track : NSObject { NSString *location; } @end

@implementation Track

-(id) init {

   [super init];
   location = [[NSString alloc] initWithString:@"None"];

   return self;
}

-(void) setLocation:(NSString*) loc {
   [loc retain];
   [location release];
   location = loc;
}

-(NSString*) location {
   return location;
}

-(void) dealloc
{
   [location release];
   [super dealloc];
}
@end
************************************************
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: pb with nsmutablearray
      • From: Nick Zitzmann <email@hidden>
    • Re: pb with nsmutablearray
      • From: Charles Steinman <email@hidden>
  • Prev by Date: Non collapsable NSSplitView
  • Next by Date: Re: Non collapsable NSSplitView
  • Previous by thread: Re: Non collapsable NSSplitView
  • Next by thread: Re: pb with nsmutablearray
  • Index(es):
    • Date
    • Thread