(Sorry guys if I sound stupid I am totally new to objective-c coming from a background in java)
Can someone please explain (or point to a document) how make a class that requires parameters? I understand how to pass parameters to methods but I got somewhat lost with passing them to classes. I am trying to make a very simple class called person. It needs two basic parameters (a name and an age) but I have no idea how to do it. In Java it would be like
Creating the object with the two parameters (name and age)
and the constructor for the person class would be like
but I just don't understand how to do it in objective-c. Could someone please explain the syntax or point me to a document. I know I probably sound really dumb but the author of my book chose to not to explain the syntax (or I haven't been able to find it). Any answer that explains passing methods to a class would be a big help, it doesn't need to be an objective-c equivalent to my above code I just really need to know how to pass some parameters to my classes.
Can someone please explain (or point to a document) how make a class that requires parameters? I understand how to pass parameters to methods but I got somewhat lost with passing them to classes. I am trying to make a very simple class called person. It needs two basic parameters (a name and an age) but I have no idea how to do it. In Java it would be like
Creating the object with the two parameters (name and age)
Code:
personX = new Person ("bob", 18);
and the constructor for the person class would be like
Code:
public Person (string name, int age) {
...code for the class
}
but I just don't understand how to do it in objective-c. Could someone please explain the syntax or point me to a document. I know I probably sound really dumb but the author of my book chose to not to explain the syntax (or I haven't been able to find it). Any answer that explains passing methods to a class would be a big help, it doesn't need to be an objective-c equivalent to my above code I just really need to know how to pass some parameters to my classes.