Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In C# we might have something like:
- public class UserAccount
- {
- [ManimumLength(8)]
- [MaximumLength(20)]
- public string { get; set; }
- }
- // UserAccount.h
- #import <Foundation/Foundation.h>
- #define EDITORTYPE @"EditorType"
- enum ValidationType
- {
- ValidateMinimumLength = 0,
- ValidateMaximumLength = 1,
- };
- @interface UserAccount : NSObject {
- }
- @property (nonatomic, retain) NSString *name;
- @end
- // UserAccount.m
- #import "UserAccount.h"
- #import "NSObject+MetadataExtensions.h"
- @implementation UserAccount
- metadata_class(UserAccount, EDITORTYPE, @"UserEditor"); // Wait, what's this?! How did we do that?
- metadata_property(name, ValidateMinimumLength, 8, ValidateMaximumLength, 20); // Again?
- @synthesize name;
- /***************************
- **************************/
- metadata_cMethod(testClassMethod, @"More", @"MetaData"); // Here too?
- + (void)testClassMethod {
- }
- /***************************
- **************************/
- + (void)unannotatedClassMethod {
- }
- @end
- // Then to get output we do things like:
- NSLog(@"Class: %@", [UserAccount classMetadata]);
- NSLog(@"Property (by name): %@", [UserAccount metadataForPropertyWithName:@"name"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement