Branch
Hash :
c3ed5b52
Author :
Date :
2018-03-11T11:11:05
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<h2>Full example</h2>
<pre><code>#import <UIKit/UIKit.h>
#import "Dependency.h"
@protocol WorldDataSource
@optional
- (NSString*)worldName;
@required
- (BOOL)allowsToLive;
@end
@interface Test : NSObject <HelloDelegate, WorldDataSource> {
NSString *_greeting;
}
@property (nonatomic, readonly) NSString *greeting;
- (IBAction) show;
@end
@implementation Test
@synthesize test=_test;
+ (id) test {
return [self testWithGreeting:@"Hello, world!\nFoo bar!"];
}
+ (id) testWithGreeting:(NSString*)greeting {
return [[[self alloc] initWithGreeting:greeting] autorelease];
}
- (id) initWithGreeting:(NSString*)greeting {
if ( (self = [super init]) ) {
_greeting = [greeting retain];
}
return self;
}
- (void) dealloc {
[_greeting release];
[super dealloc];
}
@end</code></pre>