Skip to content

Instantly share code, notes, and snippets.

@arohner
Created July 9, 2014 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arohner/aeba9c82926416e26462 to your computer and use it in GitHub Desktop.
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
Copy link
Author

arohner commented Jul 9, 2014

(lldb) bt
* thread #1: tid = 0x177be3, 0x00007fff86db7097 libobjc.A.dylib`objc_msgSend + 23, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x00007fff86db7097 libobjc.A.dylib`objc_msgSend + 23
    frame #1: 0x00007fff919eb184 Foundation`_NSDescriptionWithLocaleFunc + 41
    frame #2: 0x00007fff92b49ce4 CoreFoundation`__CFStringAppendFormatCore + 7332
    frame #3: 0x00007fff92b78263 CoreFoundation`_CFStringCreateWithFormatAndArgumentsAux + 115
    frame #4: 0x00007fff919eb12f Foundation`-[NSPlaceholderString initWithFormat:locale:arguments:] + 132
    frame #5: 0x00007fff919ee98c Foundation`+[NSString stringWithFormat:] + 170
  * frame #6: 0x0000000100033ae2 FlowClient`-[BMOEDNSymbol description](self=0x000060800002c460, _cmd=0x00007fff864e10af) + 194 at BMOEDNSymbol.m:45
    frame #7: 0x000000010031e205 libswiftFoundation.dylib`protocol witness for Swift._PrintableNSObject.description.getter : Swift.ImplicitlyUnwrappedOptional<Swift.String> in conformance ObjectiveC.NSObject : Swift._PrintableNSObject + 53
    frame #8: 0x00000001000d3e18 libswift_stdlib_core.dylib`Swift.print <A, B : Swift.OutputStream>(A, @inout B) -> () + 3048
    frame #9: 0x00000001000c6100 libswift_stdlib_core.dylib`Swift.String.convertFromStringInterpolationSegment (Swift.String.Type)<A>(A) -> Swift.String + 176
    frame #10: 0x000000010000a582 FlowClient`FlowClient.Event.EDNData (self=0x00006100000b25a0)() -> Swift.AnyObject + 402 at Event.swift:36
    frame #11: 0x000000010000aa72 FlowClient`@objc FlowClient.Event.EDNData (FlowClient.Event)() -> Swift.AnyObject + 34 at Event.swift:0
    frame #12: 0x000000010000aae7 FlowClient`FlowClient.Event.toEDN (self=0x00006100000b25a0)() -> Swift.String + 103 at Event.swift:44

@arohner
Copy link
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