Friday, 8 February 2013

My unsolved coding iOS

1) In iOS programming, I often need tiny classes with a class. But I do not want to define .h and .m for each tiny class. How can have these tiny class within a UIViewController class?

Android allows tiny classes to be defined in big class activity. Why cannot iOS? e.g .

class a(){

   class b(){


// and you can use b inside a! 

Update: Just find that struct is not supported in NSMutableArray so Struct is useless in iOS.

2) Often there is a method that i want to use in 2 different class, how do i share them. So that i do not need to edit 2 classes when i want to change the method?

- Have tried Block, it seems like block is similar to a method in class. Why have another thing? It cannot use in 2 different classes.

- Have study interface. it seems like a private method for a class..

@interface ClassName ()- (void)privateMethod;@end

Update on 160213. To have a method use in 2 classes, create the method in a common class. Make the method a class method. And here you go!

No comments:

Post a Comment