0

if i do like,i know its wrong, but can anyone give alternative solution?

for(int i = 0;i<=3;i++)
{
  myclass *obj[i] = [[myclass alloc] init];
}

1 Answer 1

1

It's kinda hard to tell, since you give no indication of what you're trying to do. Here's my best guess:

myclass *obj[4];
for (int i = 0; i < 4; i++) {
    obj[i] = [[myclass alloc] init];
}

(Note also the change to i < 4. Since the end result is to loop four times, not three, it is bad form to say i <= 3.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.