Skip to content

Instantly share code, notes, and snippets.

@arohner
Created July 9, 2014 20:26
Show Gist options
  • Select an option

  • Save arohner/aeba9c82926416e26462 to your computer and use it in GitHub Desktop.

Select an option

Save arohner/aeba9c82926416e26462 to your computer and use it in GitHub Desktop.
// 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")
@arohner

arohner commented Jul 9, 2014

Copy link
Copy Markdown
Author
-(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