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

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
Here's the code I'm using.

Code:
NSUInteger *count = 0; 
NSArray *labelArray = [[NSArray alloc] initWithObjects:// bunch of strings, nil];
    count = count + 1;
    NSString *someString = [labelArray objectAtIndex:*count];

To make sure I don't give too many details, I have modified the code, but this should be enough. Note: count is located in a .m file, just below the #import statement. The rest is in a method.

EDIT: I'm using Xcode 4.6.
 
No idea how would it help, at all. Actually it is the cause of the problem it seems.

Btw, is count += 1 inside a loop?

Hiding details does not help either, I am sure iterating through an array is no secret :p
 
Because I figured it would help.

No, that's wrong.

Integers should be declared without a "*", an referenced without a "*" either.

There are cases where you might use a pointer to an integer, but unless you know exactly what that "*" does, and why you're using it, don't.

Noobies get used to declaring objects like this:

Code:
NSObject *someObject;

And so they want to put "*"s in front of everything.

I'm thinking that's the problem you're having.

That syntax should be used for objects, but not for scalar types like int, bool, char, float, etc.
 
No idea how would it help, at all. Actually it is the cause of the problem it seems.

Duncan already addressed the majority of this but let me add: If you don't understand how something would help, don't add it or take the time to understand it well enough to know whether to add it or not.

Btw, is count += 1 inside a loop?

Based on the code you provided, no, it's not. Loops are achieved using for or while blocks.

...I am sure iterating through an array is no secret :p
It's not. You should look into fast-enumeration.
 
Duncan already addressed the majority of this but let me add: If you don't understand how something would help, don't add it or take the time to understand it well enough to know whether to add it or not.



Based on the code you provided, no, it's not. Loops are achieved using for or while blocks.


It's not. You should look into fast-enumeration.

You quoted the wrong person I guess
 
No, that's wrong.

Integers should be declared without a "*", an referenced without a "*" either.

There are cases where you might use a pointer to an integer, but unless you know exactly what that "*" does, and why you're using it, don't.

Noobies get used to declaring objects like this:

Code:
NSObject *someObject;

And so they want to put "*"s in front of everything.

I'm thinking that's the problem you're having.

That syntax should be used for objects, but not for scalar types like int, bool, char, float, etc.

Gotcha.

Thanks, everyone!

UPDATE: It works!
 
Last edited:
*I agree *although only in front of iOSsy things.


So it was the integer "count" that is there because you thought the integer
would help, but the stuff up was making it a pointer,
then the OP misunderstood because he thought it was the integer that
people were saying isn't helpful, but it's actually the pointer that people
thought wasn't helpful.
Then some further misunderstandings and apologies, and finally, an "It works!" :D

So the integer is helpful?
I would use it to address multiple arrays,
or make a connection between an NSArray object and C array
by indexing both arrays with "count".
That's why I thought the >>>integer<<< might be helpful.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.