-
Notifications
You must be signed in to change notification settings - Fork 3
/
KLFoo.m
63 lines (49 loc) · 1.05 KB
/
KLFoo.m
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// KLFoo.m
// Demo Project
//
// Created by kinglong huang on 9/7/12.
// Copyright (c) 2012 KLStudio. All rights reserved.
//
#import "KLFoo.h"
@implementation KLFoo
#pragma mark - LifeCycle
- (NSString *)foo {
return _foo;
}
- (instancetype)init {
self = [super init];
if (self) {
return self;
}
return nil;
}
- (void)dealloc {
//MRC
[_foo release];_foo = nil; //OR self.foo = nil;
[_bar release];_bar = nil; //OR self.bar = nil;
[super dealloc];
}
#pragma mark - Private
- (NSString *)foolName {
//...
return @"KLStudio";
}
#pragma mark - Public
+ (instancetype)fooWithString:(NSString *)string {
return [[[self alloc] initWithString:string] autorelease];
}
- (instancetype)initWithString:(NSString *)string {
self = [super init];
if (self) {
self.foo = [self foolName];
self.bar = [[[NSString alloc] initWithFormat:@"hi %d", 3] autorelease];
return self;
}
return nil;
}
- (BOOL)doWorkWithString:(NSString *)blah {
//...
return YES;
}
@end