• 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
Objects not being added to array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Objects not being added to array


  • Subject: Objects not being added to array
  • From: "Matthew Callis" <email@hidden>
  • Date: Sun, 17 Dec 2006 09:36:03 -0600

That special case does start adding it, but it shows me that the code
doesn't do what I inteded to do.
With this code below I expected this output:
("The Arcade Fire", "Neon Bible", None,  Indie, 2007, 254,  1,
 "The Arcade Fire",  Funeral, None, Indie, 2004, 2840, 10)

but instead it is listing every track and adding as it goes.

("The Arcade Fire", "Neon Bible", None,  Indie, 2007, 254,  1,
 "The Arcade Fire",  Funeral, None, Indie, 2004, 240, 1)
 "The Arcade Fire",  Funeral, None, Indie, 2004, 480, 2)
 "The Arcade Fire",  Funeral, None, Indie, 2004, 840, 3)
...
 "The Arcade Fire",  Funeral, None, Indie, 2004, 2840, 10)

The Code:
   NSString *cur_artist =     [[allTapes objectAtIndex:0] objectAtIndex:0];
   NSString *cur_venue =     [[allTapes objectAtIndex:0] objectAtIndex:1];
   NSString *cur_location = [[allTapes objectAtIndex:0] objectAtIndex:2];
   NSString *cur_genre =     [[allTapes objectAtIndex:0] objectAtIndex:3];
   NSString *cur_year =     [[allTapes objectAtIndex:0] objectAtIndex:4];
//  NSString *cur_length =     [[allTapes objectAtIndex:0] objectAtIndex:5];
   int cur_length = 0;
   int cur_count = 0;

   NSMutableArray * tapeBunch = [[NSMutableArray alloc] init];
   tapeBunch = [[tapeBunch retain] autorelease];

   int allofthem = [allTapes count];
   for(i = 0; i < allofthem; i++){
       NSComparisonResult artistResult, venueResult;
       artistResult = [[[allTapes objectAtIndex:i] objectAtIndex:0]
compare:cur_artist];
       venueResult = [[[allTapes objectAtIndex:i] objectAtIndex:1]
compare:cur_venue];

       if(artistResult != NSOrderedSame || venueResult != NSOrderedSame ||
i == 0){
           cur_artist        = [[allTapes objectAtIndex:i]
objectAtIndex:0];
           cur_venue        = [[allTapes objectAtIndex:i] objectAtIndex:1];
           cur_location    = [[allTapes objectAtIndex:i] objectAtIndex:2];
           cur_genre        = [[allTapes objectAtIndex:i] objectAtIndex:3];
           cur_year        = [[allTapes objectAtIndex:i] objectAtIndex:4];
           cur_length        = [[[allTapes objectAtIndex:i]
objectAtIndex:5] intValue];
           cur_count        = 1;
       }
       else{
           cur_count++;
           cur_length        += [[[allTapes objectAtIndex:i]
objectAtIndex:5] intValue];
       }
       [tapeBunch addObject:cur_artist];
       [tapeBunch addObject:cur_venue];
       [tapeBunch addObject:cur_location];
       [tapeBunch addObject:cur_genre];
       [tapeBunch addObject:cur_year];
       [tapeBunch addObject:[NSString stringWithFormat:@"%i", cur_length]];
       [tapeBunch addObject:[NSString stringWithFormat:@"%i", cur_count]];
   }
   NSLog(@"tapeBunch:\n %@", tapeBunch);
--
- Matthew
http://eludevisibility.org/
_______________________________________________

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: Objects not being added to array
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: saving jpg's in pdfs
  • Next by Date: NSScrollView custom thumbs
  • Previous by thread: Re: Objects Not being added to array
  • Next by thread: Re: Objects not being added to array
  • Index(es):
    • Date
    • Thread