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

View Single Post
Old 06-26-2009, 04:31 PM   #2 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

You almost certainly want to use an NSArray or NSMutableArray of items instead of 12 separate variables, and you probably want a custom class too. Your variable names are all too generic to tell what's going on, but you want to write something like this:

Code:
for ( (StageClass )*stage in stageArray){
     stage.count++;
     stage.stuff=0;
     stage.otherStuff=0;
     stage.animationImages = newStageImage
}
This is going to require writing your own class call StageClass, and setting up stuff and otherStuff as "properties." It's also possible to do it without your own class, with multiple arrays like stuffArray and otherStuffArray, but it's bad design and it will be difficult to maintain.

Better yet, you may be able to put the operation inside a method in StageClass, and just run that method on every object. This would cause every object in the array to call [self myMethod] .

Code:
[stageArray makeObjectsPerformSelector:@selector(myMethod)];
I know this sounds like a lot to learn, but it will really make this code simple and easier to debug.
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Online Users: 787
19 members and 768 guests
ADY, at0m87, bocaraton, charles.scholten, Domele, drviii, gabacus, hiddendemo, Hirley2324, J.Steve, Jaxen66, KarlJay, smarkmee, srilu, suresk, thitikorn, thutrangiphonedevsdk, ugur, Vineesh
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,630
Threads: 89,147
Posts: 380,342
Top Poster: BrianSlick (7,110)
Welcome to our newest member, thitikorn
Powered by vBadvanced CMPS v3.1.0

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