Reputation: 71
I am trying to set a CLLocation property (named objectLocation) of a custom class, using the below code, called from my main ViewController. Unfortunately, I receive an error telling me on the "commented" line, that the "expression is not assignable." locationsArray is an array of objects of the custom class. I really need to set this value, so any help is appreciated!
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
for (int i = 0; i < [locationsArray count]; i++) {
if ([locationsArray[i] objectLocation] == NULL) {
[locationsArray[i] objectLocation] = [locations lastObject]; //retrieves most recent location data - THIS IS THE LINE THAT RECEIVES THE ERROR
//now set up a region and start monitoring data for that region
[locationsArray[i] region] = [[CLRegion alloc]
initCircularRegionWithCenter:
[[locationsArray[i] objectLocation] coordinate]
radius:2
identifier:[NSString stringWithFormat:@"%@", [locationsArray[i] objectLocationName]]];
}
}
}
Upvotes: 0
Views: 462
Reputation: 16292
If it is a property of CLLocation
within your class and given that your locationsArray
holds the object and your locations
array does hold a CLLocation
object, then please try the following:
((<YOUR_CLASS>*)[locationsArray[i]).objectLocation = [locations lastObject];
Hope this helps.
Upvotes: 1