Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-26-2009, 03: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: 2,565
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.
__________________
smasher is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,185
Threads: 38,957
Posts: 170,914
Top Poster: smasher (2,565)
Welcome to our newest member, JaredJohnson325
Powered by vBadvanced CMPS v3.1.0

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