Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 53

Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
06/25/13 12:07 PM (12 years ago)

If statement inside of an Array

Hi All, Does anyone know if it is possible to put an if statement inside an array? Jake
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
06/25/13 12:29 PM (12 years ago)
Do you mean use an if statement to add objects or not to an array
 
Mackimack
Apple Fan
Profile
Posts: 481
Reg: Dec 30, 2010
Sweden
14,310
like
06/25/13 12:34 PM (12 years ago)
You need explain more what you try to do. An array is a list with something. You have to fill your array first, then you can take out or add somthing to that you will display.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/25/13 01:54 PM (12 years ago)
Sorry to say that like Mackimack, I'm a bit confused. But if you're looking to either 'add' to an array via an if statement, or if you're trying to retrieve something 'from' an array via an if statement, you might want to snoop around the 'parse screen data' methods from some of the 'UITableView' type menus (Simple list, menu with image, MWI Advanced). Otherwise, let us know a bit more of your situation... :) Cheers! -- Smug
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
06/25/13 02:22 PM (12 years ago)
Ok, here is more info: It is an NSArray: NSArray *arrayName = [NSArray arrayWithObjects:Object1, Object2, nil]; I would like to implement an if statement which will take out items from the array. Jake
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/25/13 02:30 PM (12 years ago)
Then ya, look in the 'parse screen data' of a few of the menus. Cheers! -- Smug
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
06/25/13 02:48 PM (12 years ago)
I was able to accomplish the adding by using: [arrayName addObject:objectName]; (The array has to be a NSMutableArray) Jake
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
06/25/13 08:37 PM (12 years ago)
That NSMutableArray is a good one to use. It comes prepackaged with a handfull of helper functions for removing objects. – removeAllObjects – removeLastObject – removeObject: – removeObject:inRange: – removeObjectAtIndex: – removeObjectsAtIndexes: – removeObjectIdenticalTo: – removeObjectIdenticalTo:inRange: – removeObjectsInArray: – removeObjectsInRange: – removeObjectsFromIndices:numIndices: Deprecated in OS X v10.6 https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html The NSMutableArray should take care of reordering the array when you remove an object.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.