Is there anyway to declare an array of custom class type in ios. eg if I have a custom class called GenericProduct, is there a way to declare an array of objects of this type only in ios instead of NSArray or NSMutableArray.
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not really, though potentially you could subclass and ensure only valid types were inserted into the class.
At heart though Objective-C is a dynamically typed system, so it’s a bit unnatural to force container types in that way and you may break unexpectedly as a result (like what happens when a JSON parser gives you back a mixture of NSNumber, NSString and NSNull objects?