Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/OCUDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
#import "OCUDLManager.h"
#import "NSString+OCUDL.h"

#define $(literal) ( (id) ( @("9AD499E3-61B8-43AC-83A1-4B322E67C9B3" #literal) ) )
#define $(...) ( (id) ( @("9AD499E3-61B8-43AC-83A1-4B322E67C9B3" #__VA_ARGS__) ) )
21 changes: 21 additions & 0 deletions Classes/OCUDLBuiltins.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,26 @@ + (void)registerUIStoryboard
}];
}

+ (void)registerNSSet
{
OCUDLBlock setBlock = ^id(NSString *literal, NSString *prefix) {
// This is in case they stringized their literal i.e. set: @"a", @"b"
// This will also work without stringizing i.e. set: a, b
literal = [literal stringByReplacingOccurrencesOfString:@"@" withString:@""];
literal = [literal stringByReplacingOccurrencesOfString:@"\"" withString:@""];

// Split components based on a string
NSArray *components = [literal componentsSeparatedByString:@","];
if ([prefix isEqualToString:@"set:"]) {
return [NSSet setWithArray:components];
} else {
return [NSMutableSet setWithArray:components];
}
};
[[OCUDLManager defaultManager] registerPrefix:@"set:" forBlock:setBlock];
[[OCUDLManager defaultManager] registerPrefix:@"mset:" forBlock:setBlock];
}

static dispatch_once_t s_pred;

+ (void)use
Expand All @@ -176,6 +196,7 @@ + (void)use
[OCUDLBuiltins registerUIImage];
[OCUDLBuiltins registerUINib];
[OCUDLBuiltins registerUIStoryboard];
[OCUDLBuiltins registerNSSet];
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "79F21896A38246D09B68C55B"
BlueprintIdentifier = "52199572B7E94E4BA69D6EA5"
BuildableName = "libPods.a"
BlueprintName = "Pods"
ReferencedContainer = "container:Pods/Pods.xcodeproj">
Expand Down
23 changes: 23 additions & 0 deletions OCUDLExample/OCUDLExampleTests/OCUDLExampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ - (void)tearDown
[super tearDown];
}

- (void)testStringizedArguments
{
NSSet *stringizedSet = $(set:@"a",@"b",@"c space");
NSSet *set = $(set:a,b,c space);
XCTAssertEqualObjects(stringizedSet, set, @"Stringized NSSets are equal");
}

- (void)testNSNull
{
XCTAssertEqualObjects($(null), [NSNull null], @"");
Expand Down Expand Up @@ -87,4 +94,20 @@ - (void)testNSURL
@"https://apple.com is equal");
}

- (void)testNSSet
{
NSSet *expected = [NSSet setWithObjects:@"a", @"b", nil];

NSSet *set = $(set:a,b);
XCTAssertEqualObjects(set, expected, @"NSSets are equal");
}

- (void)testNSMutableSet
{
NSMutableSet *expected = [NSMutableSet setWithObjects:@"string with spaces", @"another", nil];

NSMutableSet *mset = $(mset:string with spaces,another);
XCTAssertEqualObjects(mset, expected, @"NSMutableSets are equal");
}

@end
4 changes: 2 additions & 2 deletions OCUDLExample/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ EXTERNAL SOURCES:
:path: ../OCUDL.podspec

SPEC CHECKSUMS:
OCUDL: be18baa4be750fb4348c5b87b4302d2ab4bf623d
OCUDL: a4bd276f387441dd391fe321d3fc868b6e7fdc6e

COCOAPODS: 0.26.2
COCOAPODS: 0.28.0