here’s what i’m trying to convert to objective c from c#:
public class Television
{
public string Name {get; set};
public bool isOn {get; set};
public int channelNum {get; set};
public string channelName {get; set};
}
let’s say the television fairy has been to my house, and i don’t know how many televisions are in there. or, i want to make this code reusable and since everyone has a different amount of televisions in their households, i want to make this a different number at every runtime.
public List<Television> TVs = new List<Television>(4);
when i want to i can say:
TVs[3].channelNum = 34;
- in objective c, how would you put this in an array/dictionary(hashtable)? can you give me an example?
- if i created a new object every time a new Television is put in the house, and accessed its properties, is this more efficient on memory than a list class would be? it seems like a list would be easier than creating 4 array sets, wouldn’t it?
-
could someone give me an example of how this would be used if i called
Television TVs = [[Television alloc]init];
and used properties instead?
-
could i use television objects in an nsmutablearray, and just pull them out to access their properties when i need them, or when they change?
Just something to give you an idea (though it’s not very lovely code)…
Implemenation
Usage