Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // In C# we might have something like:
  2. public class UserAccount
  3. {
  4.     [ManimumLength(8)]
  5.     [MaximumLength(20)]
  6.     public string { get; set; }
  7. }
  8.  
  9.  
  10.  
  11.  
  12. // UserAccount.h
  13. #import <Foundation/Foundation.h>
  14.  
  15. #define EDITORTYPE @"EditorType"
  16.  
  17. enum ValidationType
  18. {
  19.     ValidateMinimumLength = 0,
  20.     ValidateMaximumLength = 1,
  21.    
  22. };
  23.  
  24. @interface UserAccount : NSObject {
  25.  
  26. }
  27.  
  28. @property (nonatomic, retain) NSString *name;
  29.  
  30. @end
  31.  
  32.  
  33.  
  34.  
  35. // UserAccount.m
  36. #import "UserAccount.h"
  37. #import "NSObject+MetadataExtensions.h"
  38.  
  39. @implementation UserAccount
  40. metadata_class(UserAccount, EDITORTYPE, @"UserEditor"); // Wait, what's this?! How did we do that?
  41.  
  42. metadata_property(name, ValidateMinimumLength, 8, ValidateMaximumLength, 20); // Again?
  43. @synthesize name;
  44.  
  45. /***************************
  46.  
  47.  **************************/
  48. metadata_cMethod(testClassMethod, @"More", @"MetaData"); // Here too?
  49. + (void)testClassMethod {  
  50.  
  51. }
  52.  
  53. /***************************
  54.  
  55.  **************************/
  56. + (void)unannotatedClassMethod {
  57.    
  58. }
  59.  
  60. @end
  61.  
  62.  
  63.  
  64.  
  65. // Then to get output we do things like:
  66. NSLog(@"Class: %@", [UserAccount classMetadata]);
  67. NSLog(@"Property (by name): %@", [UserAccount metadataForPropertyWithName:@"name"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement