Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-23-2008, 07:34 AM   #1 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
Default can't access array object values

I'm having a hard time accessing an NSArray I made within the same object.

in the header file:
Code:
...
@class DictEntry;

@interface DictController : NSObject {
  NSArray *entryList;
  NSMutableArray *dictEntries;
}

@property (nonatomic, retain) NSArray *entryList;
@property (nonatomic, retain) NSMutableArray *dictEntries;
...
To create the array:
Code:
dictEntries = [[NSMutableArray alloc] initWithCapacity:71080];

// Make array of dictionary entries
for ( int n = 35; n <= 71115; n++ ) {
  // Create the temporary dictionary entry
  DictEntry *tempDict = [[DictEntry alloc] init];
		
  [tempDict setEntry:[self.entryList objectAtIndex:n]];
  [dictEntries addObject:tempDict];

  [tempDict release];
}

NSLog( @"dictEntries debug after creation" );
[[dictEntries objectAtIndex: 65] debug];
To access an element of the array:
Code:
NSLog( @"dictEntries amount" );
NSLog( [NSString stringWithFormat:@"%d", [dictEntries count]] );
	
NSLog( @"dictEntries debug at access" );
[[dictEntries objectAtIndex: 65] debug];
The debug function just prints out the values of the object. It properly prints the number of entries in the array, but then it crashes when I try to run the debug function... even though it properly runs in the function which sets up this array! Does anyone see what I'm doing wrong here or can direct me to finding a solution? Thanks in advance!
chuck is offline   Reply With Quote
Old 08-24-2008, 08:29 AM   #2 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
Default

I just want to say that I solved this issue. I wasn't putting self. in front of my variables in the object.
chuck is offline   Reply With Quote
Reply

Bookmarks

Tags
array, nsarray, objectatindex

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:14 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0