What does the output of NSLog exactly mean? [duplicate] - objective-c

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
NSLog 10b meaning?
I am new to objc and iOS development. And, I have a question about NSLog. As we know, NSLog will log message like this:
2011-07-16 23:19:35.467 HelloWorld[11166:7c37] say hello to iOS.
Obviously the format is date time ProjectName, but what does the [11166:7c37] part mean?

Its a process / thread ID I believe.

Related

Objective C syntax, iOS sample code [duplicate]

This question already has answers here:
What does a type name in parentheses before a variable mean?
(3 answers)
Closed 8 years ago.
I'm learning objective-C and I was looking at some sample code from:
https://developer.apple.com/library/ios/samplecode/UsingPhotosFramework/Listings/SamplePhotosApp_AAPLAssetGridViewController_m.html#//apple_ref/doc/uid/TP40014575-SamplePhotosApp_AAPLAssetGridViewController_m-DontLinkElementID_8
I'm confused about this line of code here:
CGSize cellSize = ((UICollectionViewFlowLayout *)self.collectionViewLayout).itemSize;
I understand that it's trying to get the itemSize property and store it into cellSize, but I have no idea what ((UICollectionViewFlowLayout *)self.collectionViewLayout) is all about. Can someone break it down for me? Is there another way to write this line of code?
What it means is:
Cast self.collectionViewLayout to be of UICollectionViewFlowLayout type. Then of self.collectionViewLayout get the itemSize property. Finally, save everything is a property of type CGSize.
I believe is a elegant and concise way of writing it.

Is there an ObjC macro or function to get all the argument values received by a method? [duplicate]

This question already has answers here:
Pass all arguments of a method into NSLog
(2 answers)
Closed 8 years ago.
I know that NSStringFromSelector(_cmd) gives the name of the current method. I use that in a debugging macro to print what method I'm in. I would like to also get the method's arguments as strings so I can print them too. I'm thinking of something like *argv[] in C.
Is there any built-in facility for that?
Yes, c++ (and Objective-C) support va_list.
Do something like this:
- (void)do:(va_list)args
{
// do something with all your args
}
And use it like this:
[self do:#"foo", #"bar"]

Combining two strings for a label's text [duplicate]

This question already has answers here:
Setting a cell's text with multiple JSON objects
(3 answers)
Closed 9 years ago.
Real beginners question here. I'm doing some tutorials and I'm expanding on them with scenarios that might come in to play.
Anyhow, I know that the following works:
lblCopyStatus.text = #"Test";
But how would do:
lblCopyStatus.text = #"Test" & lbltest.text;
e.g. get the text from another label into the text. I hope that makes sense :)
For example:
lblCopyStatus.text = [NSString stringWithFormat:#"Test %#", lbltest.text];

objective c method asterisk [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Asterisk in parenthesis in Objective-C… What does it mean?
does anyone can find some resource or detail explanation about following code
-(void) add:(Cal *)c;
I am very new to obj-c.what does asterisk means in that code?
Thanks.
It means that the argument for the method is a pointer to an instance of a "Cal" object.

Evaluate math expression in string? (NSString) [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What is a fast C or Objective-C math parser?
I have a NSString which represents a calculation eg. #"(10+10)*2" and I want to evaluate the string as if it was actually something like this;
double result = (10+10)*2;
What is the most straightforward approach to take in iOS?
Take a look at Dave DeLong's DDMathParser framework.
You can use GCMathParser.