Can't get rid of a build error, need Objective-C help


#1

I’m trying to do the Geocode challenge and am running into a dumb problem which I can’t resolve.

I KNOW this is my newness to Objective-C, I’m not understanding some syntax nuance.

Here is the problem code:

NSString *subTitleString = [[NSString alloc] initWithFormat:@"%@, %@", [ptrPMK locality], [ptrPMK countryCode]]; MapPoint *mp = [[MapPoint alloc] initWithCoordinate:[ptrLocation coordinate] title:[locationTitleField text] subtitle:subTitleString];

When I build this, I get a failure “Expected ‘:’ before ‘]’ token”, at the line “subtitle:subTitleString];” Subtitle is defined as an (NSString *) in the MapPoint declaration.


#2

I think I figured it out. I should put subTitleString inside parenthesis?

subtitle:(subTitleString)];

What has me confused is that in the RandomPossessions exercise, we had a code fragment that looked like:

[code] NSString *randomSerialNumber = [NSString stringWithFormat:@"%c%c%c%c%c",
‘0’ + random() % 10,
‘A’ + random() % 26,
‘0’ + random() % 10,
‘A’ + random() % 26,
‘0’ + random() % 10];

Possession *newPossession = [[self alloc] initWithPossessionName:randomName 
												  valueInDollars:randomValue
													serialNumber:randomSerialNumber];

[/code]

I’m not understanding the difference. Why do we need () in one case, but not in the other?