-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path5544D84A-E428-4EAD-AEFD-9B18A876A2EE.codesnippet
More file actions
47 lines (44 loc) · 1.78 KB
/
5544D84A-E428-4EAD-AEFD-9B18A876A2EE.codesnippet
File metadata and controls
47 lines (44 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>Entity helper</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>ClassImplementation</string>
</array>
<key>IDECodeSnippetContents</key>
<string>class func searchRequest(placeID: String) -> NSFetchRequest<PlaceEntity> {
let fetch = NSFetchRequest<PlaceEntity>(entityName: "PlaceEntity");
fetch.predicate = NSPredicate(format: "placeID == %@",placeID)
return fetch
}
static func makeInstance() -> PlaceEntity {
if #available(iOS 10.0, *) {
return PlaceEntity(context: AppDelegate.share.context)
} else {
return NSEntityDescription.insertNewObject(forEntityName: "PlaceEntity", into: AppDelegate.share.context) as! PlaceEntity
}
}
static func getall() -> [PlaceEntity]? {
let request: NSFetchRequest<PlaceEntity> = PlaceEntity.fetchRequest()
return try? AppDelegate.share.context.fetch(request)
}
static func search(by placeID: String) -> PlaceEntity? {
let searchRequest: NSFetchRequest<PlaceEntity> = PlaceEntity.searchRequest(placeID: placeID)
return (try? AppDelegate.share.context.fetch(searchRequest))?.first
}
</string>
<key>IDECodeSnippetIdentifier</key>
<string>5544D84A-E428-4EAD-AEFD-9B18A876A2EE</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetTitle</key>
<string>Swift 3: Entity Helper</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>