Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

junmoney83

macrumors newbie
Original poster
Mar 3, 2010
20
0
Code:
@interface testTable2ViewController : UIViewController 
{
	NSMutableArray **indexStore;
}

@property(nonatomic , retain) NSMutableArray **indexStore;

@end

@implementation testTable2ViewController
@synthesize indexStore;

- (void)viewDidLoad 
{
	NSMutableArray *jung[10];

	for (NSInteger i = 0; i <10; i++)
	{
		jung[i] = [[NSMutableArray alloc]init];
		indexStore[i] = [[NSMutableArray alloc]init];
	}//for
}


@end

//////////////////////////////////////////////////////
jung = [[NSMutableArray alloc]init]; is working good....
but indexStore = [[NSMutableArray alloc]init]; can't work
Error Message is EXC_BAD_ACCESS...

why it is not working?
 
why it is not working?

Because indexStore is nil.

You define the variable in the header. Good.

You use the contents of the variable in viewDidLoad. Bad.

You need something that will run before viewDidLoad, which will initialize the testTable2ViewController so it's ready for use. Normally, that's an -init method of some kind.
 
but this is working...

jung = [[NSMutableArray alloc]init];
is working good.
 
jung = [[NSMutableArray alloc]init];
is working good.


Because the jung array is declared as an array. You didn't declare indexStore as an array.

If you want an array, you have to define the variable as an array. For example, if you want indexStore to be an array of 10 NSMutable-pointers, you should use this in your .h file:
Code:
NSMutableArray *indexStore[10];
It seems like you don't fully understand the difference between pointer-to-pointer (indexStore, for example) and array-of-pointer (jung, for example).


If you explain what you're trying to accomplish, then it might be easier to offer advice. All we know is that you're having trouble, but since we don't know what you're trying to do, we can't really offer any specific advice.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.