I’m getting a strange error when assigning a value to one of my objects. As best as I can figure out, the compiler thinks I’m assigning to a read only variable. It gives me “lvalue required as left operand of assignment” on the myPlace.publicLocation… line.
I’m sure it’s a classic novice mistake – where am I going wrong?
CSPlace *myPlace;
myPlace.publicLocation.coordinate.latitude =
[[separatedData objectAtIndex:0] floatValue];
class:
#import <CoreLocation/CLLocation.h>
@interface CSPlace : NSObject {
CLLocation *publicLocation;
}
@property (copy, nonatomic) CLLocation *publicLocation;
@end
#import "CSPlace.h"
@implementation CSPlace
@synthesize publicLocation;
@end
CLLocation an immutable class with respect to latitude and longitude. So you cannot modify its latitude. You have to create a new object:
Being immutable is the whole meaning of having such an initializer.