Created
July 9, 2014 20:26
-
-
Save arohner/aeba9c82926416e26462 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BMOEDNSymbol.h | |
#import <Foundation/Foundation.h> | |
@interface BMOEDNSymbol : NSObject <NSCopying> | |
@property (strong, nonatomic, readonly) NSString *ns; | |
@property (strong, nonatomic, readonly) NSString *name; | |
-(instancetype)initWithNamespace:(NSString *)ns | |
name:(NSString *)name; | |
+(BMOEDNSymbol *)symbolWithNamespace:(NSString *)ns | |
name:(NSString *)name; | |
-(BOOL)isEqualToSymbol:(BMOEDNSymbol *)object; | |
@end | |
//// BMOEDNSymbol.m | |
@implementation BMOEDNSymbol | |
-(instancetype)initWithNamespace:(NSString *)ns | |
name:(NSString *)name { | |
if (name == nil) @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Symbol name must not be nil." userInfo:nil]; | |
if (self = [super init]) { | |
_ns = ns; | |
_name = name; | |
} | |
return self; | |
} | |
// swift | |
BMOEDNKeyword(namespace:"foo", name:"bar") |
Author
arohner
commented
Jul 9, 2014
-(NSString *)description {
if (self.ns == nil) return [self.name description];
else return [NSString stringWithFormat:@"%@/%@",self.ns,self.name];
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment