Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
74840977
Commit
74840977
authored
Apr 27, 2016
by
Brent Gulanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JSON serialization tests.
parent
9437fc4b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
465 additions
and
15 deletions
+465
-15
BUYPropertyDescriptionAdditionsTests.m
...bile Buy SDK Tests/BUYPropertyDescriptionAdditionsTests.m
+169
-15
contents
...YTestModel.xcdatamodeld/BUYTestModel.xcdatamodel/contents
+62
-0
TestModel.h
Mobile Buy SDK/Mobile Buy SDK Tests/TestModel.h
+52
-0
TestModel.m
Mobile Buy SDK/Mobile Buy SDK Tests/TestModel.m
+150
-0
project.pbxproj
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
+23
-0
NSPropertyDescription+BUYAdditions.m
...le Buy SDK/Additions/NSPropertyDescription+BUYAdditions.m
+1
-0
BUYDateTransformer.m
...DK/Mobile Buy SDK/Value Transformers/BUYDateTransformer.m
+8
-0
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYPropertyDescriptionAdditionsTests.m
View file @
74840977
...
...
@@ -25,33 +25,187 @@
//
#import <XCTest/XCTest.h>
#import <CoreData/CoreData.h>
@interface
BUYPropertyDescriptionAdditionsTests
:
XCTestCase
#import "BUYFlatCollectionTransformer.h"
#import "BUYDateTransformer.h"
#import "NSPropertyDescription+BUYAdditions.h"
#import "TestModel.h"
static
NSString
*
const
RootEntity
=
@"Root"
;
static
NSString
*
const
BranchEntity
=
@"Branch"
;
static
NSString
*
const
LeafEntity
=
@"Leaf"
;
static
NSString
*
const
NestEntity
=
@"Nest"
;
static
NSString
*
const
BirdEntity
=
@"Bird"
;
@interface
BUYPropertyDescriptionAdditionsTests
:
XCTestCase
@property
(
nonatomic
)
NSManagedObjectModel
*
model
;
@property
(
nonatomic
)
TestModelManager
*
modelManager
;
@end
@implementation
BUYPropertyDescriptionAdditionsTests
-
(
void
)
setUp
{
[
super
setUp
];
// Put setup code here. This method is called before the invocation of each test method in the class.
+
(
void
)
initialize
{
if
(
self
==
[
BUYPropertyDescriptionAdditionsTests
class
])
{
[
NSValueTransformer
setValueTransformer
:[
BUYFlatCollectionTransformer
arrayTransformer
]
forName
:
@"Array"
];
[
NSValueTransformer
setValueTransformer
:[
BUYFlatCollectionTransformer
setTransformer
]
forName
:
@"Set"
];
}
}
-
(
instancetype
)
initWithInvocation
:
(
NSInvocation
*
)
invocation
{
self
=
[
super
initWithInvocation
:
invocation
];
if
(
self
)
{
self
.
modelManager
=
[[
TestModelManager
alloc
]
init
];
self
.
model
=
self
.
modelManager
.
model
;
}
return
self
;
}
-
(
NSEntityDescription
*
)
entityForName
:
(
NSString
*
)
entityName
{
return
self
.
model
.
entitiesByName
[
entityName
];
}
-
(
NSAttributeDescription
*
)
attributeWithName
:
(
NSString
*
)
attributeName
forEntity
:
(
NSString
*
)
entityName
{
return
[[
self
entityForName
:
entityName
]
attributesByName
][
attributeName
];
}
-
(
NSRelationshipDescription
*
)
relationshipWithName
:
(
NSString
*
)
propertyName
forEntity
:
(
NSString
*
)
entityName
{
return
[[
self
entityForName
:
entityName
]
relationshipsByName
][
propertyName
];
}
-
(
void
)
testJSONTransformerName
{
XCTAssertEqualObjects
(
BUYDateTransformerName
,
[
self
attributeWithName
:
@"date"
forEntity
:
LeafEntity
].
JSONValueTransformerName
);
}
-
(
void
)
testJSONPropertyKey
{
XCTAssertEqualObjects
(
@"createDate"
,
[
self
attributeWithName
:
@"date"
forEntity
:
LeafEntity
].
JSONPropertyKey
);
}
-
(
void
)
testJSONValueTransformer
{
XCTAssertEqualObjects
([
BUYFlatCollectionTransformer
class
],
[[
self
attributeWithName
:
@"tags"
forEntity
:
LeafEntity
].
JSONValueTransformer
class
]);
}
-
(
void
)
testInteger
{
NSAttributeDescription
*
idAttribute
=
[
self
attributeWithName
:
@"identifier"
forEntity
:
RootEntity
];
NSNumber
*
identifier
=
@10001
;
XCTAssertEqualObjects
(
identifier
,
[
idAttribute
buy_JSONForValue
:
identifier
]);
XCTAssertEqualObjects
(
identifier
,
[
idAttribute
buy_valueForJSON
:
identifier
object
:
nil
]);
}
-
(
void
)
testString
{
NSAttributeDescription
*
stringAttribute
=
[
self
attributeWithName
:
@"name"
forEntity
:
RootEntity
];
NSString
*
name
=
@"MyRoot"
;
XCTAssertEqualObjects
(
name
,
[
stringAttribute
buy_JSONForValue
:
name
]);
XCTAssertEqualObjects
(
name
,
[
stringAttribute
buy_valueForJSON
:
name
object
:
nil
]);
}
-
(
void
)
testDecimalNumber
{
NSAttributeDescription
*
decimalAttribute
=
[
self
attributeWithName
:
@"age"
forEntity
:
RootEntity
];
NSString
*
ageString
=
@"145"
;
NSDecimalNumber
*
age
=
[
NSDecimalNumber
decimalNumberWithString
:
ageString
];
XCTAssertEqualObjects
(
ageString
,
[
decimalAttribute
buy_JSONForValue
:
age
]);
XCTAssertEqualObjects
(
age
,
[
decimalAttribute
buy_valueForJSON
:
ageString
object
:
nil
]);
}
-
(
void
)
testDate
{
NSAttributeDescription
*
dateAttribute
=
[
self
attributeWithName
:
@"date"
forEntity
:
LeafEntity
];
NSString
*
dateString
=
@"1970-01-01T01:17:59+0000"
;
NSDate
*
date
=
[
NSDate
dateWithTimeIntervalSince1970
:
4679
.
0
];
XCTAssertEqualObjects
(
dateString
,
[
dateAttribute
buy_JSONForValue
:
date
]);
XCTAssertEqualObjects
(
date
,
[
dateAttribute
buy_valueForJSON
:
dateString
object
:
nil
]);
}
-
(
void
)
testURL
{
// the Root.url attribute declares "attributeValueClass = NSURL; JSONTransformerName = BUYURL"
NSAttributeDescription
*
urlAttribute
=
[
self
attributeWithName
:
@"url"
forEntity
:
RootEntity
];
NSString
*
urlString
=
@"https://www.example.com/api/model.json?id=100"
;
NSURL
*
url
=
[
NSURL
URLWithString
:
urlString
];
XCTAssertEqualObjects
(
urlString
,
[
urlAttribute
buy_JSONForValue
:
url
]);
XCTAssertEqualObjects
(
url
,
[
urlAttribute
buy_valueForJSON
:
urlString
object
:
nil
]);
}
-
(
void
)
testFlatArray
{
NSAttributeDescription
*
arrayDescription
=
[
self
attributeWithName
:
@"ornaments"
forEntity
:
BranchEntity
];
NSString
*
ornamentsString
=
@"one two three two one"
;
NSArray
*
ornaments
=
@[
@"one"
,
@"two"
,
@"three"
,
@"two"
,
@"one"
];
XCTAssertEqualObjects
(
ornamentsString
,
[
arrayDescription
buy_JSONForValue
:
ornaments
]);
XCTAssertEqualObjects
(
ornaments
,
[
arrayDescription
buy_valueForJSON
:
ornamentsString
object
:
nil
]);
}
-
(
void
)
testFlatSet
{
NSAttributeDescription
*
setDescription
=
[
self
attributeWithName
:
@"tags"
forEntity
:
LeafEntity
];
NSString
*
tagsString
=
@"blue green red"
;
NSSet
*
tags
=
[
NSSet
setWithArray
:@[
@"red"
,
@"green"
,
@"blue"
]];
XCTAssertEqualObjects
(
tags
,
[
setDescription
buy_valueForJSON
:
tagsString
object
:
nil
]);
NSString
*
jsonString
=
[
setDescription
buy_JSONForValue
:
tags
];
NSSet
*
actual
=
[
NSSet
setWithArray
:[
jsonString
componentsSeparatedByString
:
@" "
]];
XCTAssertEqualObjects
(
actual
,
tags
);
}
-
(
void
)
tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[
super
tearDown
];
-
(
void
)
testRelationship
{
Branch
*
branch
=
[
self
.
modelManager
buy_objectWithEntityName
:
BranchEntity
JSONDictionary
:
nil
];
NSRelationshipDescription
*
nestRelationship
=
[
self
relationshipWithName
:
@"nest"
forEntity
:
BranchEntity
];
NSDictionary
*
expected
=
@{
@"egg_count"
:
@2
};
id
<
BUYObject
>
object
=
[
nestRelationship
buy_valueForJSON
:
expected
object
:
branch
];
NSDictionary
*
actual
=
[
nestRelationship
buy_JSONForValue
:
object
];
XCTAssertEqualObjects
(
actual
,
expected
);
}
-
(
void
)
testExample
{
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
-
(
void
)
testRecursiveRelationship
{
Branch
*
branch
=
[
self
.
modelManager
buy_objectWithEntityName
:
BranchEntity
JSONDictionary
:
nil
];
NSRelationshipDescription
*
nestRelationship
=
[
self
relationshipWithName
:
@"nest"
forEntity
:
BranchEntity
];
NSDictionary
*
json
=
@{
@"bird_id"
:
@501
};
id
object
=
[
nestRelationship
buy_valueForJSON
:
json
object
:
branch
];
XCTAssertEqualObjects
(
@501
,
[[
object
bird
]
identifier
]);
id
actual
=
[
nestRelationship
buy_JSONForValue
:
object
];
XCTAssertEqualObjects
(
actual
,
json
);
}
-
(
void
)
testPerformanceExample
{
// This is an example of a performance test case.
[
self
measureBlock
:
^
{
// Put the code you want to measure the time of here.
}];
-
(
void
)
testToManyRelationship
{
Branch
*
branch
=
[
self
.
modelManager
buy_objectWithEntityName
:
BranchEntity
JSONDictionary
:
nil
];
NSRelationshipDescription
*
leafRelationship
=
[
self
relationshipWithName
:
@"leaves"
forEntity
:
BranchEntity
];
id
json
=
@[
@{
@"date"
:
@"2001-01-21T00:00:00 +0000"
,
@"tags"
:
@"test one two"
},
@{
@"date"
:
@"2010-06-11T00:00:00 +0000"
,
@"tags"
:
@"phone"
},
@{
@"date"
:
@"2013-11-03T00:00:00 +0000"
,
@"tags"
:
@"song tune album"
},
];
NSSet
*
object
=
[
leafRelationship
buy_valueForJSON
:
json
object
:
branch
];
XCTAssertTrue
([
object
isKindOfClass
:[
NSSet
class
]]);
XCTAssertTrue
([[
object
anyObject
]
isKindOfClass
:[
Leaf
class
]]);
NSSet
*
expected
=
[
NSSet
setWithObjects
:
[
NSSet
setWithObjects
:
@"test"
,
@"one"
,
@"two"
,
nil
],
[
NSSet
setWithObjects
:
@"phone"
,
nil
],
[
NSSet
setWithObjects
:
@"song"
,
@"tune"
,
@"album"
,
nil
],
nil
];
XCTAssertEqualObjects
(
expected
,
[
object
valueForKey
:
@"tags"
]);
}
@end
Mobile Buy SDK/Mobile Buy SDK Tests/BUYTestModel.xcdatamodeld/BUYTestModel.xcdatamodel/contents
0 → 100644
View file @
74840977
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model
userDefinedModelVersionIdentifier=
""
type=
"com.apple.IDECoreDataModeler.DataModel"
documentVersion=
"1.0"
lastSavedToolsVersion=
"10171"
systemVersion=
"15E65"
minimumToolsVersion=
"Xcode 7.0"
>
<entity
name=
"Bird"
representedClassName=
"Bird"
syncable=
"YES"
>
<attribute
name=
"colour"
optional=
"YES"
attributeType=
"String"
syncable=
"YES"
/>
<attribute
name=
"identifier"
optional=
"YES"
attributeType=
"Integer 64"
defaultValueString=
"0"
syncable=
"YES"
/>
<relationship
name=
"nests"
optional=
"YES"
toMany=
"YES"
deletionRule=
"Nullify"
destinationEntity=
"Nest"
inverseName=
"bird"
inverseEntity=
"Nest"
syncable=
"YES"
/>
</entity>
<entity
name=
"Branch"
representedClassName=
"Branch"
syncable=
"YES"
>
<attribute
name=
"ornaments"
optional=
"YES"
attributeType=
"Transformable"
syncable=
"YES"
>
<userInfo>
<entry
key=
"attributeValueClass"
value=
"NSArray"
/>
<entry
key=
"JSONValueTransformer"
value=
"Array"
/>
</userInfo>
</attribute>
<relationship
name=
"leaves"
optional=
"YES"
toMany=
"YES"
deletionRule=
"Cascade"
destinationEntity=
"Leaf"
inverseName=
"branch"
inverseEntity=
"Leaf"
syncable=
"YES"
/>
<relationship
name=
"nest"
optional=
"YES"
maxCount=
"1"
deletionRule=
"Cascade"
destinationEntity=
"Nest"
inverseName=
"branch"
inverseEntity=
"Nest"
syncable=
"YES"
/>
<relationship
name=
"root"
optional=
"YES"
maxCount=
"1"
deletionRule=
"Nullify"
destinationEntity=
"Root"
inverseName=
"branches"
inverseEntity=
"Root"
syncable=
"YES"
/>
</entity>
<entity
name=
"Leaf"
representedClassName=
"Leaf"
syncable=
"YES"
>
<attribute
name=
"date"
optional=
"YES"
attributeType=
"Date"
syncable=
"YES"
>
<userInfo>
<entry
key=
"JSONPropertyKey"
value=
"createDate"
/>
</userInfo>
</attribute>
<attribute
name=
"tags"
optional=
"YES"
attributeType=
"Transformable"
syncable=
"YES"
>
<userInfo>
<entry
key=
"attributeValueClass"
value=
"NSSet"
/>
<entry
key=
"JSONValueTransformer"
value=
"Set"
/>
</userInfo>
</attribute>
<relationship
name=
"branch"
optional=
"YES"
maxCount=
"1"
deletionRule=
"Nullify"
destinationEntity=
"Branch"
inverseName=
"leaves"
inverseEntity=
"Branch"
syncable=
"YES"
/>
</entity>
<entity
name=
"Nest"
representedClassName=
"Nest"
syncable=
"YES"
>
<attribute
name=
"eggCount"
optional=
"YES"
attributeType=
"Integer 16"
syncable=
"YES"
/>
<relationship
name=
"bird"
optional=
"YES"
maxCount=
"1"
deletionRule=
"Nullify"
destinationEntity=
"Bird"
inverseName=
"nests"
inverseEntity=
"Bird"
syncable=
"YES"
>
<userInfo>
<entry
key=
"JSONPropertyKey"
value=
"bird_id"
/>
</userInfo>
</relationship>
<relationship
name=
"branch"
optional=
"YES"
maxCount=
"1"
deletionRule=
"Nullify"
destinationEntity=
"Branch"
inverseName=
"nest"
inverseEntity=
"Branch"
syncable=
"YES"
/>
</entity>
<entity
name=
"Root"
representedClassName=
"Root"
syncable=
"YES"
>
<attribute
name=
"age"
optional=
"YES"
attributeType=
"Decimal"
defaultValueString=
"0.0"
syncable=
"YES"
/>
<attribute
name=
"identifier"
optional=
"YES"
attributeType=
"Integer 64"
defaultValueString=
"0"
syncable=
"YES"
/>
<attribute
name=
"name"
optional=
"YES"
attributeType=
"String"
syncable=
"YES"
/>
<attribute
name=
"url"
optional=
"YES"
attributeType=
"Transformable"
syncable=
"YES"
>
<userInfo>
<entry
key=
"attributeValueClassName"
value=
"NSURL"
/>
<entry
key=
"JSONTransformerName"
value=
"BUYURL"
/>
</userInfo>
</attribute>
<relationship
name=
"branches"
optional=
"YES"
toMany=
"YES"
deletionRule=
"Cascade"
destinationEntity=
"Branch"
inverseName=
"root"
inverseEntity=
"Branch"
syncable=
"YES"
/>
</entity>
<elements>
<element
name=
"Root"
positionX=
"-63"
positionY=
"-18"
width=
"128"
height=
"120"
/>
<element
name=
"Branch"
positionX=
"-63"
positionY=
"0"
width=
"128"
height=
"105"
/>
<element
name=
"Leaf"
positionX=
"-45"
positionY=
"18"
width=
"128"
height=
"90"
/>
<element
name=
"Bird"
positionX=
"-36"
positionY=
"45"
width=
"128"
height=
"90"
/>
<element
name=
"Nest"
positionX=
"-27"
positionY=
"54"
width=
"128"
height=
"90"
/>
</elements>
</model>
\ No newline at end of file
Mobile Buy SDK/Mobile Buy SDK Tests/TestModel.h
0 → 100644
View file @
74840977
//
// TestModel.h
// Mobile Buy SDK
//
// Created by Brent Gulanowski on 2016-04-27.
// Copyright © 2016 Shopify Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BUYObjectProtocol.h"
#import "BUYModelManagerProtocol.h"
@class
NSManagedObjectModel
;
@interface
TestModelManager
:
NSObject
<
BUYModelManager
>
@property
(
nonatomic
)
NSManagedObjectModel
*
model
;
@end
@interface
TestModel
:
NSObject
<
BUYObject
>
@property
(
nonatomic
,
strong
)
TestModelManager
*
modelManager
;
@end
@class
Leaf
,
Nest
;
@
interface
Bird
:
TestModel
@property
(
nonatomic
)
NSNumber
*
identifier
;
@property
(
nonatomic
)
NSString
*
colour
;
+
(
instancetype
)
birdWithIdentifier
:(
NSNumber
*
)
identifier
;
@end
@interface
Branch
:
TestModel
@property
(
nonatomic
)
NSArray
<
NSString
*>
*
ornaments
;
@property
(
nonatomic
)
NSSet
<
Leaf
*>
*
leaves
;
@property
(
nonatomic
)
Nest
*
nest
;
@end
@interface
Leaf
:
TestModel
@property
(
nonatomic
)
NSDate
*
date
;
@property
(
nonatomic
)
NSSet
<
NSString
*>
*
tags
;
@end
@interface
Nest
:
TestModel
@property
(
nonatomic
)
NSNumber
*
eggCount
;
@property
(
nonatomic
)
Bird
*
bird
;
@end
@interface
Root
:
TestModel
@property
(
nonatomic
)
NSNumber
*
identifier
;
@property
(
nonatomic
)
NSDecimalNumber
*
age
;
@property
(
nonatomic
)
NSString
*
name
;
@property
(
nonatomic
)
NSURL
*
url
;
@end
Mobile Buy SDK/Mobile Buy SDK Tests/TestModel.m
0 → 100644
View file @
74840977
//
// TestModel.m
// Mobile Buy SDK
//
// Created by Brent Gulanowski on 2016-04-27.
// Copyright © 2016 Shopify Inc. All rights reserved.
//
#import "TestModel.h"
#import "NSEntityDescription+BUYAdditions.h"
#import <CoreData/CoreData.h>
@implementation
TestModelManager
-
(
instancetype
)
init
{
self
=
[
super
init
];
if
(
self
)
{
self
.
model
=
[
NSManagedObjectModel
mergedModelFromBundles
:@[[
NSBundle
bundleForClass
:[
self
class
]]]];
}
return
self
;
}
-
(
NSEntityDescription
*
)
buy_entityWithName
:
(
NSString
*
)
entityName
{
return
self
.
model
.
entitiesByName
[
entityName
];
}
-
(
Class
)
managedModelClassForEntityName
:
(
NSString
*
)
entityName
{
return
[[
self
buy_entityWithName
:
entityName
]
buy_managedObjectClass
];
}
-
(
id
<
BUYObject
>
)
buy_objectWithEntityName
:
(
NSString
*
)
entityName
JSONDictionary
:
(
NSDictionary
*
)
JSON
{
return
[(
id
)[[
self
managedModelClassForEntityName
:
entityName
]
alloc
]
initWithModelManager
:
self
JSONDictionary
:
JSON
];
}
-
(
NSArray
<
id
<
BUYObject
>>
*
)
buy_objectsWithEntityName
:
(
NSString
*
)
entityName
JSONArray
:
(
NSArray
*
)
JSON
{
NSMutableArray
*
array
=
[
NSMutableArray
array
];
for
(
NSDictionary
*
dict
in
JSON
)
{
[
array
addObject
:[
self
buy_objectWithEntityName
:
entityName
JSONDictionary
:
dict
]];
}
return
array
;
}
// We don't need these methods for testing
-
(
id
<
BUYObject
>
)
buy_objectWithEntityName
:
(
NSString
*
)
entityName
identifier
:
(
NSNumber
*
)
identifier
{
return
[
entityName
isEqualToString
:[
Bird
entityName
]]
?
[
Bird
birdWithIdentifier
:
identifier
]
:
nil
;
}
-
(
NSArray
<
id
<
BUYObject
>>
*
)
buy_objectsWithEntityName
:
(
NSString
*
)
entityName
identifiers
:
(
NSArray
*
)
identifiers
{
return
nil
;
}
-
(
void
)
buy_refreshCacheForObject
:
(
id
<
BUYObject
>
)
object
{}
-
(
BOOL
)
buy_purgeObject
:
(
id
<
BUYObject
>
)
object
error
:
(
NSError
*
__autoreleasing
*
)
error
{
return
YES
;
}
-
(
BOOL
)
buy_purgeObjectsWithEntityName
:
(
NSString
*
)
entityName
matchingPredicate
:
(
NSPredicate
*
)
predicate
{
return
YES
;
}
@end
#pragma mark -
@implementation
TestModel
@synthesize
modelManager
=
_modelManager
;
-
(
instancetype
)
initWithModelManager
:(
id
<
BUYModelManager
>
)
modelManager
JSONDictionary
:(
NSDictionary
*
)
dictionary
{
self
=
[
super
init
];
if
(
self
)
{
self
.
modelManager
=
modelManager
;
self
.
JSONDictionary
=
dictionary
;
}
return
self
;
}
-
(
NSDictionary
*
)
JSONDictionary
{
return
[
self
.
entity
buy_JSONForObject
:
self
];
}
-
(
void
)
setJSONDictionary
:
(
NSDictionary
*
)
JSONDictionary
{
[
self
.
entity
buy_updateObject
:
self
withJSON
:
JSONDictionary
];
}
-
(
NSDictionary
*
)
JSONEncodedProperties
{
NSMutableDictionary
*
properties
=
[[
self
.
entity
buy_JSONEncodedProperties
]
mutableCopy
];
for
(
NSString
*
relationshipName
in
self
.
entity
.
relationshipsByName
)
{
NSRelationshipDescription
*
relationship
=
properties
[
relationshipName
];
if
(
relationship
.
inverseRelationship
.
deleteRule
==
NSCascadeDeleteRule
)
{
[
properties
removeObjectForKey
:
relationshipName
];
}
}
return
properties
;
}
+
(
NSPredicate
*
)
fetchPredicateWithJSON
:
(
NSDictionary
*
)
JSONDictionary
{
return
nil
;
}
+
(
NSString
*
)
entityName
{
return
NSStringFromClass
([
self
class
]);
}
-
(
NSEntityDescription
*
)
entity
{
return
[
self
.
modelManager
buy_entityWithName
:[[
self
class
]
entityName
]];
}
+
(
BOOL
)
tracksDirtyProperties
{
return
NO
;
}
+
(
BOOL
)
isPersistentClass
{
return
NO
;
}
@end
#pragma mark - Models
@implementation
Bird
+
(
instancetype
)
birdWithIdentifier
:(
NSNumber
*
)
identifier
{
Bird
*
bird
=
[[
self
alloc
]
init
];
bird
.
identifier
=
identifier
;
return
bird
;
}
@end
@implementation
Branch
@end
@implementation
Leaf
@end
@implementation
Nest
@end
@implementation
Root
@end
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
View file @
74840977
...
...
@@ -119,6 +119,8 @@
849810971CB7E07900CFAB58
/* BUYFlatCollectionTransformer.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
849810901CB7E07900CFAB58
/* BUYFlatCollectionTransformer.h */
;
};
849810981CB7E07900CFAB58
/* BUYFlatCollectionTransformer.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
849810911CB7E07900CFAB58
/* BUYFlatCollectionTransformer.m */
;
};
849810991CB7E07900CFAB58
/* BUYFlatCollectionTransformer.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
849810911CB7E07900CFAB58
/* BUYFlatCollectionTransformer.m */
;
};
84CA59BC1CD1378100B2A956
/* BUYTestModel.xcdatamodeld in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
84CA59BA1CD1378100B2A956
/* BUYTestModel.xcdatamodeld */
;
};
84CA59C01CD1609400B2A956
/* TestModel.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
84CA59BF1CD1609400B2A956
/* TestModel.m */
;
};
9003969B1B601DF400226B73
/* BUYCartLineItem.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
900396991B601DF400226B73
/* BUYCartLineItem.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9003969C1B601DF400226B73
/* BUYCartLineItem.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9003969A1B601DF400226B73
/* BUYCartLineItem.m */
;
};
900396AC1B627CB900226B73
/* BUYProductView.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
900396AA1B627CB900226B73
/* BUYProductView.h */
;
};
...
...
@@ -467,6 +469,9 @@
8498108F1CB7E07900CFAB58
/* BUYDeliveryRangeTransformer.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYDeliveryRangeTransformer.m
;
sourceTree
=
"<group>"
;
};
849810901CB7E07900CFAB58
/* BUYFlatCollectionTransformer.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYFlatCollectionTransformer.h
;
sourceTree
=
"<group>"
;
};
849810911CB7E07900CFAB58
/* BUYFlatCollectionTransformer.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYFlatCollectionTransformer.m
;
sourceTree
=
"<group>"
;
};
84CA59BB1CD1378100B2A956
/* BUYTestModel.xcdatamodel */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.xcdatamodel
;
path
=
BUYTestModel.xcdatamodel
;
sourceTree
=
"<group>"
;
};
84CA59BE1CD1609400B2A956
/* TestModel.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
TestModel.h
;
sourceTree
=
"<group>"
;
};
84CA59BF1CD1609400B2A956
/* TestModel.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
TestModel.m
;
sourceTree
=
"<group>"
;
};
900396991B601DF400226B73
/* BUYCartLineItem.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYCartLineItem.h
;
sourceTree
=
"<group>"
;
};
9003969A1B601DF400226B73
/* BUYCartLineItem.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYCartLineItem.m
;
sourceTree
=
"<group>"
;
};
900396AA1B627CB900226B73
/* BUYProductView.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
lineEnding
=
0
;
name
=
BUYProductView.h
;
path
=
"Product View/BUYProductView.h"
;
sourceTree
=
"<group>"
;
xcLanguageSpecificationIdentifier
=
xcode.lang.objcpp
;
};
...
...
@@ -795,6 +800,7 @@
90F592ED1B0D5EFE0026B382
/* Mobile Buy SDK Tests */
=
{
isa
=
PBXGroup
;
children
=
(
84CA59BA1CD1378100B2A956
/* BUYTestModel.xcdatamodeld */
,
90F592F91B0D5F4C0026B382
/* BUYApplePayAdditionsTest.m */
,
8491102E1CCE708900E53B93
/* BUYArrayAdditionsTests.m */
,
90F592FA1B0D5F4C0026B382
/* BUYCartTest.m */
,
...
...
@@ -822,6 +828,8 @@
906CF1AE1B8B660F001F7D5B
/* PKContact Test Objects */
,
90F592EE1B0D5EFE0026B382
/* Supporting Files */
,
BEB9AE721BA73E6C00575F8A
/* test_shop_data.json */
,
84CA59BE1CD1609400B2A956
/* TestModel.h */
,
84CA59BF1CD1609400B2A956
/* TestModel.m */
,
);
path
=
"Mobile Buy SDK Tests"
;
sourceTree
=
"<group>"
;
...
...
@@ -1487,8 +1495,10 @@
90BBCD731B87B6BA00FCCE51
/* BUYPKContact.m in Sources */
,
849110331CCE708900E53B93
/* BUYStringAdditionsTests.m in Sources */
,
906CF1B11B8B66AE001F7D5B
/* BUYCNPostalAddress.m in Sources */
,
84CA59BC1CD1378100B2A956
/* BUYTestModel.xcdatamodeld in Sources */
,
8491103C1CCE731900E53B93
/* BUYURLAdditionsTests.m in Sources */
,
849110401CCE9DFB00E53B93
/* BUYPropertyDescriptionAdditionsTests.m in Sources */
,
84CA59C01CD1609400B2A956
/* TestModel.m in Sources */
,
906CF1AD1B8B5F7D001F7D5B
/* BUYNSPersonNameComponents.m in Sources */
,
BE98DB5C1BB1F4D000C29564
/* OHHTTPStubsResponse+Helpers.m in Sources */
,
849110311CCE708900E53B93
/* BUYArrayAdditionsTests.m in Sources */
,
...
...
@@ -1948,6 +1958,19 @@
defaultConfigurationName
=
Release
;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
84CA59BA1CD1378100B2A956
/* BUYTestModel.xcdatamodeld */
=
{
isa
=
XCVersionGroup
;
children
=
(
84CA59BB1CD1378100B2A956
/* BUYTestModel.xcdatamodel */
,
);
currentVersion
=
84CA59BB1CD1378100B2A956
/* BUYTestModel.xcdatamodel */
;
path
=
BUYTestModel.xcdatamodeld
;
sourceTree
=
"<group>"
;
versionGroupType
=
wrapper.xcdatamodel
;
};
/* End XCVersionGroup section */
};
rootObject
=
F773741519C770CB0039681C
/* Project object */
;
}
Mobile Buy SDK/Mobile Buy SDK/Additions/NSPropertyDescription+BUYAdditions.m
View file @
74840977
...
...
@@ -65,6 +65,7 @@ static NSString * const BUYAttributeValueClassNameKey = @"attributeValueClassNam
[
NSValueTransformer
setValueTransformer
:[[
BUYIdentityTransformer
alloc
]
init
]
forName
:
BUYIdentityTransformerName
];
// attribute type transformers
[
NSValueTransformer
setValueTransformer
:[[
BUYDateTransformer
alloc
]
init
]
forName
:
BUYDateTransformerName
];
[
NSValueTransformer
setValueTransformer
:[[
BUYDecimalNumberTransformer
alloc
]
init
]
forName
:
BUYDecimalNumberTransformerName
];
// value type transformers
...
...
Mobile Buy SDK/Mobile Buy SDK/Value Transformers/BUYDateTransformer.m
View file @
74840977
...
...
@@ -25,6 +25,7 @@
//
#import "BUYDateTransformer.h"
#import "NSDateFormatter+BUYAdditions.h"
NSString
*
const
BUYDateTransformerName
=
@"BUYDate"
;
...
...
@@ -34,6 +35,13 @@ NSString * const BUYDateTransformerName = @"BUYDate";
@implementation
BUYDateTransformer
-
(
instancetype
)
init
{
NSDateFormatter
*
formatter
=
[
NSDateFormatter
dateFormatterForPublications
];
formatter
.
timeZone
=
[
NSTimeZone
timeZoneForSecondsFromGMT
:
0
];
return
[
self
initWithDateFormatter
:
formatter
];
}
-
(
instancetype
)
initWithDateFormatter
:
(
NSDateFormatter
*
)
formatter
{
self
=
[
super
init
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment