UICollectionView autosize height

How do I properly resize a UICollectionView so that it fully displays its contents? I have tried many things, including setting its frame, calling reloadData and invalidating the layout: self.collectionView.contentSize = CGSizeMake(300, 2000); self.collectionView.frame = CGRectMake(0, 0, 300, 2000); [self.collectionView reloadData]; [self.collectionView.collectionViewLayout invalidateLayout]; but none of this has any effect. After pressing the button I … Read more

What is the difference between inheritance and Categories in Objective-C

Can some one explain to me the difference between categories and inheritance in Objective C? I’ve read the entry in Wikipedia and the discussion on categories there doesn’t look any different to that of inheritance. I also looked at the discussion on the topic in the book “Open iPhone Development” and I still don’t get … Read more

What does @class do in Objective-C?

Can anyone please explain me what does @class declaration do in Objective-C and what are the cases in which we should use this declaration? Answer It’s a forward declaration. It essentially tells the compiler that there’s a class of that name. I use it in the interface declarations: @class Foo; @interface Bar : NSObject { … Read more

Suppressing “‘…’ is deprecated” when using respondsToSelector

I’m supporting 10.4+ by picking the most-current API at runtime: if ([fileManager respondsToSelector:@selector(removeItemAtPath:error:)]) [fileManager removeItemAtPath:downloadDir error:NULL]; else [fileManager removeFileAtPath:downloadDir handler:nil]; In this case, 10.5 and up will use removeItemAtPath:error: and 10.4 will use removeFileAtPath:handler:. Great, but I still get compiler warnings for the old methods: warning: ‘removeFileAtPath:handler:’ is deprecated [-Wdeprecated-declarations] Is there a syntax of … Read more

How does cellForRowAtIndexPath work?

I HAVE READ apple documentation and it’s not understandable for such a beginner in Objective-C as me. I’m trying to implement multicolumn UITableView following this link example and it just doesn’t work so i need to comprehend how cellForRowAtIndexPath work, cause for me personally this method seems pretty complicated. 1) What does it return? UITableViewCell? … Read more