Mantle makes it easy to write a simple model layer for your Cocoa or Cocoa Touch application.
To start building the framework, clone this repository and then run script/bootstrap
.
This will automatically pull down any dependencies.
// MTLManagedObjectAdapter.m | |
- (NSPredicate *)uniquingPredicateForModel:(MTLModel<MTLManagedObjectSerializing> *)model { | |
NSSet *propertyKeys = nil; | |
if ([self.modelClass respondsToSelector:@selector(propertyKeysForManagedObjectUniquing)]) { | |
propertyKeys = [self.modelClass propertyKeysForManagedObjectUniquing]; | |
} | |
NSPredicate *predicate = nil; | |
for (NSString *propertyKey in propertyKeys) { |
Running 136 tests: | |
........................................................................................................................................ | |
# ----- XCode (OCUnit) Test Output -------------------- | |
Test Case '-[AsyncSpecTest testAsyncSpec]' started. | |
Test Case '-[AsyncSpecTest testAsyncSpec]' passed (0.036 seconds). | |
Test Case '-[AsyncSpecTest2 testBeforeAllAndAfterAllHooks]' started. | |
Test Case '-[AsyncSpecTest2 testBeforeAllAndAfterAllHooks]' passed (0.000 seconds). |
@interface FooTests : XCTestCase | |
@end | |
@implementation FooTests | |
- (void)testAnd { | |
expect(@"foo") | |
.to.beKindOfClass(NSString.class) | |
.and.equal(@"foo"); |
// No blocks-as-properties, just classic arguments | |
NSArray *tweets = [[[[[Underscore | |
array:results] | |
filter:Underscore.isDictionary] | |
reject:^(NSDictionary *tweet) { | |
return [tweet[@"iso_language_code"] isEqualToString:@"en"]; | |
}] | |
map:^(NSDictionary *tweet) { | |
NSString *name = tweet[@"from_user_name"]; |
Inbefore: im wald, morgen |
import Prelude | |
public struct Lens<A, B> { | |
private let get: A -> B | |
private let set: (A, B) -> A | |
public init(get: A -> B, set: (A, B) -> A) { | |
self.get = get | |
self.set = set | |
} |
import Foundation | |
typealias JSONDictionary = [String: AnyObject] | |
/// Attempts to load a data from a given URL. | |
func loadData(URL: NSURL) -> Either<NSError, NSData> { | |
if let data = NSData(contentsOfURL: URL) { | |
return Either.Right(Box(data)) | |
} else { | |
// In a real world scenario, we'd have a more useful error :-) |
{ | |
"name": "SBJson", | |
"version": "4.0.2", | |
"license": { | |
"type": "BSD", | |
"text": " Copyright (C) 2007-2015 Stig Brautaset. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n * Neither the name of the author nor the names of its contributors may be used\n to endorse or promote products derived from this software without specific\n prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT L |
NS_ASSUME_NONNULL_BEGIN | |
void Log(NSString *foo) { | |
NSLog(@"%@", foo); | |
} | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
NSDictionary *stuff = @{ | |
@"a": @"Test" |