Skip to content

Commit 7eb3cba

Browse files
committed
Update README.md
1 parent c6b4f9d commit 7eb3cba

File tree

1 file changed

+3
-108
lines changed

1 file changed

+3
-108
lines changed

README.md

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let encryptedStack = EncryptedDATAStack(modelName:"MyAppModel", key:"yourHashKey
4545

4646
**Objective-C**
4747
``` objc
48-
DATAStack *dataStack = [[EncryptedDATAStack alloc] initWithModelName:@"MyAppModel"];
48+
DATAStack *dataStack = [[EncryptedDATAStack alloc] initWithModelName:@"MyAppModel" key:@"yourHashKey"];
4949
```
5050
5151
- Using a custom bundle.
@@ -66,104 +66,6 @@ let encryptedStack = DATAStackmodelName:(modelName:"MyAppModel", key:"yourHashKe
6666
let encryptedStack = DATAStack(modelName:"MyAppModel", key:"yourHashKey", bundle: NSBundle.mainBundle(), storeName: "CustomStoreName", containerURL: sharedURL)
6767
```
6868

69-
## Main Thread NSManagedObjectContext
70-
71-
Getting access to the NSManagedObjectContext attached to the main thread is as simple as using the `mainContext` property.
72-
73-
```swift
74-
self.encryptedStack.mainContext
75-
```
76-
77-
or
78-
79-
```swift
80-
self.encryptedStack.viewContext
81-
```
82-
83-
## Background Thread NSManagedObjectContext
84-
85-
You can easily create a new background NSManagedObjectContext for data processing. This block is completely asynchronous and will be run on a background thread.
86-
87-
To be compatible with NSPersistentContainer you can also use `performBackgroundTask` instead of `performInNewBackgroundContext`.
88-
89-
**Swift**
90-
```swift
91-
func createUser() {
92-
self.dataStack.performInNewBackgroundContext { backgroundContext in
93-
let entity = NSEntityDescription.entityForName("User", inManagedObjectContext: backgroundContext)!
94-
let object = NSManagedObject(entity: entity, insertIntoManagedObjectContext: backgroundContext)
95-
object.setValue("Background", forKey: "name")
96-
object.setValue(NSDate(), forKey: "createdDate")
97-
try! backgroundContext.save()
98-
}
99-
}
100-
```
101-
102-
**Objective-C**
103-
```objc
104-
- (void)createUser {
105-
[self.dataStack performInNewBackgroundContext:^(NSManagedObjectContext * _Nonnull backgroundContext) {
106-
NSEntityDescription *entity = [NSEntityDescription entityForName:@"User" inManagedObjectContext:backgroundContext];
107-
NSManagedObject *object = [[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:backgroundContext];
108-
[object setValue:@"Background" forKey:@"name"];
109-
[object setValue:[NSDate date] forKey:@"createdDate"];
110-
[backgroundContext save:nil];
111-
}];
112-
}
113-
```
114-
115-
When using Xcode's Objective-C autocompletion the `backgroundContext` parameter name doesn't get included. Make sure to add it.
116-
117-
## Clean up
118-
119-
Deleting the `.sqlite` file and resetting the state of your **DATAStack** is as simple as just calling `drop`.
120-
121-
**Swift**
122-
```swift
123-
try self.dataStack.drop()
124-
```
125-
126-
**Objective-C**
127-
```objc
128-
[self.dataStack forceDrop];
129-
```
130-
131-
## Testing
132-
133-
**DATAStack** is optimized for unit testing and it runs synchronously in testing enviroments. **EncryptedDATAStack** maintains its compatibility with the only difference that the storage type used is SQLite.
134-
135-
You can create a stack that uses in memory store like this if your Core Data model is located in your app bundle:
136-
137-
**Swift**
138-
```swift
139-
let encryptedStack = EncryptedDATAStack(modelName: "MyAppModel", key:"yourHashKey", bundle: NSBundle.mainBundle())
140-
```
141-
142-
**Objective-C**
143-
```objc
144-
DATAStack *dataStack = [[DATAStack alloc] initWithModelName:@"MyAppModel"
145-
bundle:[NSBundle mainBundle]
146-
storeType:DATAStackStoreTypeInMemory];
147-
```
148-
149-
If your Core Data model is located in your test bundle:
150-
151-
**Swift**
152-
```swift
153-
let dataStack = DATAStack(modelName: "MyAppModel", key:"yourHashKey", bundle: NSBundle(forClass: Tests.self))
154-
```
155-
156-
**Objective-C**
157-
```objc
158-
DATAStack *dataStack = [[DATAStack alloc] initWithModelName:@"MyAppModel"
159-
bundle:[NSBundle bundleForClass:[self class]]
160-
storeType:DATAStackStoreTypeInMemory];
161-
```
162-
163-
## Migrations
164-
165-
Originally, if `DATAStack` has troubles creating your persistent coordinator because a migration wasn't properly handled it will destroy your data and create a new sqlite file. --This features has yet to be tested--
166-
16769
## Installation
16870

16971
Attention: A copy of DATAStack.swift is already included in this pod.
@@ -173,14 +75,7 @@ Attention: A copy of DATAStack.swift is already included in this pod.
17375
```ruby
17476
use_frameworks!
17577

176-
pod 'EncryptedDATAStack'
177-
```
178-
179-
**EncryptedDATAStack** is also available through [Carthage](https://github.com/Carthage/Carthage). To install
180-
it, simply add the following line to your Cartfile:
181-
182-
```ruby
183-
github 'flipacholas/EncryptedDATAStack'
78+
pod 'EncryptedDATAStack', :git => 'https://github.com/flipacholas/EncryptedDATAStack.git'
18479
```
18580

18681
## Improvements
@@ -197,4 +92,4 @@ Elvis Nuñez, [@3lvis](https://twitter.com/3lvis) and Project iMAS, [project-ima
19792

19893
## License
19994

200-
**EncryptedDATAStack** like **DATAStack** is available under the MIT license. See the LICENSE file for more info.
95+
**EncryptedDATAStack** like **DATAStack** is available under the MIT license. See the LICENSE file for more info.

0 commit comments

Comments
 (0)