Skip to content

Commit c6388a9

Browse files
committed
Issue #13 - cleaning up ivar storage
Remove @synthesize & use self.
1 parent 07e50e2 commit c6388a9

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

Classes/git/PBGitRef.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ extern NSString * const kGitXBranchRefPrefix;
2020
extern NSString * const kGitXRemoteRefPrefix;
2121

2222

23-
@interface PBGitRef : NSObject <PBGitRefish> {
24-
NSString* ref;
25-
}
23+
@interface PBGitRef : NSObject <PBGitRefish>
24+
25+
@property (nonatomic, strong, readonly) NSString* ref;
2626

2727
// <PBGitRefish>
2828
- (NSString *) refishName;
@@ -46,6 +46,6 @@ extern NSString * const kGitXRemoteRefPrefix;
4646

4747
+ (PBGitRef*) refFromString: (NSString*) s;
4848
- (PBGitRef*) initWithString: (NSString*) s;
49-
@property(readonly) NSString* ref;
49+
5050

5151
@end

Classes/git/PBGitRef.m

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
NSString * const kGitXBranchRefPrefix = @"refs/heads/";
1919
NSString * const kGitXRemoteRefPrefix = @"refs/remotes/";
2020

21+
@interface PBGitRef ()
22+
@property(nonatomic, strong) NSString* ref;
23+
@end
2124

2225
@implementation PBGitRef
2326

24-
@synthesize ref;
25-
2627
- (NSString *) tagName
2728
{
2829
if (![self isTag])
@@ -44,7 +45,7 @@ - (NSString *) remoteName
4445
if (![self isRemote])
4546
return nil;
4647

47-
return (NSString *)[[ref componentsSeparatedByString:@"/"] objectAtIndex:2];
48+
return (NSString *)[[self.ref componentsSeparatedByString:@"/"] objectAtIndex:2];
4849
}
4950

5051
- (NSString *) remoteBranchName
@@ -68,30 +69,30 @@ - (NSString *) type
6869

6970
- (BOOL) isBranch
7071
{
71-
return [ref hasPrefix:kGitXBranchRefPrefix];
72+
return [self.ref hasPrefix:kGitXBranchRefPrefix];
7273
}
7374

7475
- (BOOL) isTag
7576
{
76-
return [ref hasPrefix:kGitXTagRefPrefix];
77+
return [self.ref hasPrefix:kGitXTagRefPrefix];
7778
}
7879

7980
- (BOOL) isRemote
8081
{
81-
return [ref hasPrefix:kGitXRemoteRefPrefix];
82+
return [self.ref hasPrefix:kGitXRemoteRefPrefix];
8283
}
8384

8485
- (BOOL) isRemoteBranch
8586
{
8687
if (![self isRemote])
8788
return NO;
8889

89-
return ([[ref componentsSeparatedByString:@"/"] count] > 3);
90+
return ([[self.ref componentsSeparatedByString:@"/"] count] > 3);
9091
}
9192

9293
- (BOOL) isEqualToRef:(PBGitRef *)otherRef
9394
{
94-
return [ref isEqualToString:[otherRef ref]];
95+
return [self.ref isEqualToString:[otherRef ref]];
9596
}
9697

9798
- (PBGitRef *) remoteRef
@@ -109,7 +110,11 @@ + (PBGitRef*) refFromString: (NSString*) s
109110

110111
- (PBGitRef*) initWithString: (NSString*) s
111112
{
112-
ref = s;
113+
self = [super init];
114+
if (!self) {
115+
return nil;
116+
}
117+
self.ref = s;
113118
return self;
114119
}
115120

@@ -127,14 +132,16 @@ + (BOOL)isKeyExcludedFromWebScript:(const char *)name {
127132

128133
- (NSString *) refishName
129134
{
130-
return ref;
135+
return self.ref;
131136
}
132137

133138
- (NSString *) shortName
134139
{
135-
if ([self type])
136-
return [ref substringFromIndex:[[self type] length] + 7];
137-
return ref;
140+
if ([self type]) {
141+
return [self.ref substringFromIndex:[[self type] length] + 7];
142+
}
143+
144+
return self.ref;
138145
}
139146

140147
- (NSString *) refishType

0 commit comments

Comments
 (0)