/OCGeneric

Basis Generic Support in Objective-C.

Primary LanguageObjective-C

OCGeneric

Basis Generic Support in Objective-C.

  • Including OCGenerics.h

  • Register the class you want to use in NSArray

    GENERIC(NSString)
    GENERIC(NSNumber)
  • Declaring a faked NSMuatbleArray like this
    NSMutableArray(NSString) *strAry = [[NSMutableArray(NSString) alloc] init];
    NSMutableArray(NSNumber) *numberAry = [[NSMutableArray(NSNumber) alloc] init];
  • Type Recognize

    The Xcode will figure out the wrong type when you want to add a NSNumber object into an NSString Array

2014-04-16 4 52 40

  • Extensions

    You can make some extentions based on this by adding more functions into OCGenerics.h