I am looking for a way to store references to variables inside a NSMutableArray. As variables are going to be created dynamically based upon what the user has chosen, I want to be able to simply sort through this array and get references to these created variables. In case it matters, I am creating a iPhone project. However, when I attempt to do this using the following code:
for (int a = 0; a < 10; a++)
{
UIView *tempView;
[listingOfViews addObject:tempView];
}
for (int a = 0; a < [listingOfViews count]; a++)
{
[listingOfViews objectAtIndex:a] = defaultViewStructure;
}
It gives me this error: “error: lvalue required as left operand of assignment”
Any ideas?
EDIT: Also, I get this error: “error: request for member ‘size’ in something not a structure or union”
When I attempt to do
for (int a = 0; a < [listingOfViews count]; a++)
{
[listingOfViews objectAtIndex:a].size.height = ...
}
What you mean is:
But it’ll crash when you try to put those uninitialized tempView pointers into the array. What are you really trying to do here? I think it may be time to step back and start with the basics of Objective-C. It looks like you’re trying to port C++ concepts directly into ObjC, and they do things very differently.
You may want to start with Programming in Objective-C, and then probably Cocoa Programming for Mac OS X. (The latter is Mac-based, rather than iPhone, but it’s still the best starting point.)