Hi,
I get the error (Lvalue required as left operand of assignment) for this code:
[[addAlertViewController alertsArray] = [NSMutableArray arrayWithObjects:nil] retain];
How can I fix it?
Hi,
I get the error (Lvalue required as left operand of assignment) for this code:
[[addAlertViewController alertsArray] = [NSMutableArray arrayWithObjects:nil] retain];
How can I fix it?
Try this :
addAlertViewController.alertsArray = [[NSMutableArray arrayWithObjects:nil] retain];
However, if you have declared alertsArray property to retain, then you don't need to send the retain message.
The appropriate Code is as follows:
[addAlertViewController setAlertsArray:[NSMutableArray arrayWithObjects:nil]];
Be careful that you have declared in your @interface
of addAlertViewController
's Class:
@property (nonatomic, retain) NSMutableArray *alertsArray;
And in your implementation file
@synthesize alertsArray;
Knowing what an lvalue and rvalue will help when deciphering compiler warnings. A lvalue is something that will be assigned and a rvalue is something that can do the assigning. More info on wikipedia
An rvalue can also be a lvalue, like in the case of a = b = c (where c is an rvalue to lvalue b, but then b is a rvalue to the lvalue a).
anytime you see "lvalue required" then look on the left of the = operator, there is an error there.