K
K
Karetski2014-12-27 00:13:03
Objective-C
Karetski, 2014-12-27 00:13:03

How to pass an NSMutableArray with objects of the same class to a method?

I need to make sure that I can pass an NSMutableArray with objects of only one type to my method. Like List in C#. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
An, 2014-12-27
@Karetski

Ideally, refuse to operate NSMutableView, and make the class that contains it a container by adding the methods
-addObject
-removeObject
-(NSArray*) objects
And either control uniqueness at the adding stage or at the extraction stage (-objects). Through the same Array Filtering. Well, either before passing the array as a parameter, carry out the same filtering. Unfortunately, or perhaps fortunately, arrays in foundation can contain any objects
. By the way, what you want to do is perfectly done in swift . Objective c and swift code mixes without problems. And in general, it will be easier to move from c # to swift

W
warranty_voider, 2014-12-27
@warranty_voider

No way. Foundation does not have typed containers. You can write your own container that will check the type of elements, you can give it at the mercy of the called function, the implementation will be the same

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question