Search code examples
objective-cnslog

Objective-C - NSLog - "%@" Referencing Character


I'm working through a BNR iOS Programming text and I came across this piece of code:

 NSLog(@"%@", [items objectAtIndex:i]);

I am unsure of what "%@" is used for. I've seen other formats for referencing integers or characters, but I've never seen this.

I even checked this reference here and it had nothing.

Thanks!


Solution

  • %@ is for printing objective-c objects.

    To be a bit more precise. Every object is able to override

    -(NSString *)description
    

    This method is called when you use %@. It depends on the object what info of the object it will return in the NSString.