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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

Thread: EXC_BAD_ACCESS
View Single Post
Old 02-15-2010, 01:14 AM   #2 (permalink)
mistergod
Registered Member
 
Join Date: Jan 2010
Posts: 31
mistergod is on a distinguished road
Default

Quote:
Originally Posted by themaster View Post
hello everyone
i was working on a simple game that in which some nsarrays must be initiated with some uibuttons .So i initialized it at the [view did load] later i schedule the main game loop the problem is when the method returns all these data are erased or somehow unexisting and ever since i try and access any of it's elements a runtime error raises (EXC_BAD_ACCESS)
like so:

NSArray *bees;
- (void)viewDidLoad {
[super viewDidLoad];
bees=[NSArray arrayWithObjects:[UIButton buttonWithType:UIButtonTypeRoundedRect],nil];
timer=[NSTimer scheduledTimerWithTimeInterval:1/60 target:self selector:@selector(gameloop) userInfo:nil repeats:YES];
}
-(void)gameloop{
UIButton *temp=[bees objectAtIndex:0];//problem here <----------------
}
sure i made the @synthesize and @proprety;

i ve been searching the internet looking for a solution on where exactly to initiate objects but all i could get is that there is a view did load and a init which i know nothing about
so please if anyone could tell me what's wrong or even point me to an article explaining the viewdidload and it's behavior and the init method
thanks in advance and i hope i can repay u someday.
You are creating autorelease array which is deleted when the pool is drained.
You need to retain the NSArray like this:

[[NSArray arrayWithObjects:[UIButton buttonWithType:UIButtonTypeRoundedRect],nil] retain];

Best regards!
mistergod is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,476
Threads: 94,040
Posts: 402,626
Top Poster: BrianSlick (7,978)
Welcome to our newest member, policy1
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:24 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.