array in objective c

i have doubt in how to increase the order under NSLOg statement.
for e.g my code is

 int anBray[ ] = {0,5, 89, 34,9,189,9,18,9 34,89, 34,2,600,-2,0};

 int i;    

NSLog (@"Input:");

     for (i=0; i<sizeof(anBray)/sizeof(int); i++)
    NSLog(@ " anBray[i]= %i ",anBray[i]); 

actually i am getting the output-:

  • Is there any reason to declare ivars if you're using properties exclusively in Objective-C?
  • How to open preferences/settings with iOS 5.1?
  • NSURLSession + server with self signed cert
  • Accuracy of NSTimer
  • EXC_ARITHMETIC when accessing random elements of NSArray
  • Accessing View in awakeFromNib?
  •                                anBray[i]=0                               
                                   anBray[i]=5
                                   anBray[i]=89.....and so on.
    

    but how can i get output like this-:

                                     anBray[0]=0
                                     anBray[1]=5
                                     anBray[2]=89....and so on.
    

    please any one help me thanks…

    4 Solutions Collect From Internet About “array in objective c”

    Fixed that for you:

    for (i=0; i<sizeof(anBray)/sizeof(int); i++) {
       NSLog(@ " anBray[%d]= %d ",i,anBray[i]); 
     }
    

    Change NSLog(@ " anBray[i]= %i ",anBray[i],anBray[i]); to NSLog(@ " anBray[%i]= %i ",i,anBray[i]);

    You can use this code

     for (i=0; i<sizeof(anBray)/sizeof(int); i++) {
       NSLog(@ " anBray[%d]= %d ",i,anBray[i]); 
     }
    

    May this will help you..

    for (i=0; i<sizeof(anBray)/sizeof(int); i++)
        NSLog(@ " anBray[%d]= %i ",i,anBray[i]);