This question already has answers here:
What is the Java equivalent of Objective-C's NSDictionary?
(3 answers)
Closed 9 years ago.
I am interested in creating the java equivalent of a Map data structure that looks as follows:
Map <Object ---> NSMutableArray of objects>
or
Map<Object,Array<Object>>
Can anyone provide guidance on what would be the best way of doing this in objective c as I am fairly new to the language.
Objective-c does not have typed collections. You just create NSMutableDictionary instance, and put NSMutableArray into the values.
Related
This question already has answers here:
What does a type name in parentheses before a variable mean?
(3 answers)
Closed 8 years ago.
I'm learning objective-C and I was looking at some sample code from:
https://developer.apple.com/library/ios/samplecode/UsingPhotosFramework/Listings/SamplePhotosApp_AAPLAssetGridViewController_m.html#//apple_ref/doc/uid/TP40014575-SamplePhotosApp_AAPLAssetGridViewController_m-DontLinkElementID_8
I'm confused about this line of code here:
CGSize cellSize = ((UICollectionViewFlowLayout *)self.collectionViewLayout).itemSize;
I understand that it's trying to get the itemSize property and store it into cellSize, but I have no idea what ((UICollectionViewFlowLayout *)self.collectionViewLayout) is all about. Can someone break it down for me? Is there another way to write this line of code?
What it means is:
Cast self.collectionViewLayout to be of UICollectionViewFlowLayout type. Then of self.collectionViewLayout get the itemSize property. Finally, save everything is a property of type CGSize.
I believe is a elegant and concise way of writing it.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What kind of object does #[obj1, obj2] create?
Looking at the Master-Detail Template in Xcode, in the App Delegate the SplitViewController's view controllers are set like so:
self.splitViewController.viewControllers = #[masterNavigationController, detailNavigationController];
I don't know what the purpose of the # sign is before the square brackets. Is this just how NSArrays are made when not using [NSArray arrayWithObjects:]?
It's a new syntax feature. It's syntactic sugar for creating an array (NSArray) with the given objects.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Asterisk in parenthesis in Objective-C… What does it mean?
does anyone can find some resource or detail explanation about following code
-(void) add:(Cal *)c;
I am very new to obj-c.what does asterisk means in that code?
Thanks.
It means that the argument for the method is a pointer to an instance of a "Cal" object.
This question already has answers here:
Multi-dimensional NSArray object
(3 answers)
Closed 8 years ago.
In objective C how can I add specific numeric values to an array at given points (for example row3 column6) And how can I then also retrieve that value to compare it to another array at that same given point? When I try using examples I found online I get memory leaks so how do you all initiate them? What's the probably allocating / deallocating methods, etc.
Objective c is a super set of c so you can follow all the same rules of c programming for declaring and using arrays. ARC (if using ios5) will not manage the memory for these objects because they are not objective c objects so you'll have to manually allocate and destroy the objects yourself. This tutorial should get you started:
http://www.cprogramming.com/tutorial/lesson8.html
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
sorting in nsmutable array
I have 2 NSMutableArray array. I have to sort it. Is there any function defined in Objective-c for direct sort.
like
NSMutableArray *sortedarray_variable= (sorting method) array_variable;
Where sorting method returns sorted array.
Of course. NSArray provides several methods