Swift 3 - Core Data - create object - arrays

So I am trying to fetch my data from my core data database, put it into objects and then into an array which I then callback.
func getCoffeeBrandsFromDB(callback: #escaping (_ dbCoffeeBrands: Array<Any>)-> ()) {
//create a fetch request, telling it about the entity
print("running getCBFDB")
var coffeeBrandArray = Array<Any>()
let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "CoffeeBrand")
do {
let searchResults = try getContext().fetch(fetchRequest)
print ("num of results = \(searchResults.count)")
for brands in searchResults as! [NSManagedObject] {
let brand = CoffeeBrand()
brand.dataBaseId = brands.value(forKey: "dataBaseId") as! Int64
brand.brandName = brands.value(forKey: "brandName") as? String
brand.numberOfCoffeesNeeded = brands.value(forKey: "numberOfCoffeesNeeded") as! Int32
coffeeBrandArray.append(brand)
print("brands virker med \(brand.brandName!)")
}
print("CcffeeBrandArray.count is: \(coffeeBrandArray.count)")
callback(coffeeBrandArray)
} catch {
print("Error with request: \(error)")
}
}
When I run getCoffeeBrandsFromDB I get this errorlog:
running getCBFDB
num of results = 4
2017-02-08 15:47:02.179211 Keebin_development_1[8373:626945] [error] error: CoreData: error: Failed to call designated initializer on NSManagedObject class 'CoffeeBrand'
CoreData: error: CoreData: error: Failed to call designated initializer on NSManagedObject class 'CoffeeBrand'
2017-02-08 15:47:02.180 Keebin_development_1[8373:626945] -[CoffeeBrand setDataBaseId:]: unrecognized selector sent to instance 0x608000279e80
2017-02-08 15:47:02.189 Keebin_development_1[8373:626945] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CoffeeBrand setDataBaseId:]: unrecognized selector sent to instance 0x608000279e80'
*** First throw call stack:
(
0 CoreFoundation 0x0000000110c36d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000011027721e objc_exception_throw + 48
2 CoreFoundation 0x0000000110ca6f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x0000000110bbc005 ___forwarding___ + 1013
4 CoreFoundation 0x0000000110bbbb88 _CF_forwarding_prep_0 + 120
5 Keebin_development_1 0x000000010fc20e5c _TF20Keebin_development_121getCoffeeBrandsFromDBFT8callbackFGSaP__T__T_ + 1804
6 Keebin_development_1 0x000000010fc2d314 _TFC20Keebin_development_126LoyaltyCardsViewController11viewDidLoadfT_T_ + 180
7 Keebin_development_1 0x000000010fc2d5e2 _TToFC20Keebin_development_126LoyaltyCardsViewController11viewDidLoadfT_T_ + 34
8 UIKit 0x00000001111fca3d -[UIViewController loadViewIfRequired] + 1258
9 UIKit 0x000000011123d28f -[UINavigationController _layoutViewController:] + 55
10 UIKit 0x000000011123db77 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 471
11 UIKit 0x000000011123dcee -[UINavigationController _startTransition:fromViewController:toViewController:] + 133
12 UIKit 0x000000011123eef9 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
13 UIKit 0x000000011123ffdb -[UINavigationController __viewWillLayoutSubviews] + 58
14 UIKit 0x0000000111436dd7 -[UILayoutContainerView layoutSubviews] + 223
15 UIKit 0x000000011111fab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
16 QuartzCore 0x00000001161ffbf8 -[CALayer layoutSublayers] + 146
17 QuartzCore 0x00000001161f3440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
18 QuartzCore 0x00000001161f32be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x0000000116181318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
20 QuartzCore 0x00000001161ae3ff _ZN2CA11Transaction6commitEv + 475
21 UIKit 0x0000000111053d9b _UIApplicationFlushRunLoopCATransactionIfTooLate + 206
22 UIKit 0x000000011185e77c __handleEventQueue + 5672
23 CoreFoundation 0x0000000110bdb761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24 CoreFoundation 0x0000000110bc098c __CFRunLoopDoSources0 + 556
25 CoreFoundation 0x0000000110bbfe76 __CFRunLoopRun + 918
26 CoreFoundation 0x0000000110bbf884 CFRunLoopRunSpecific + 420
27 GraphicsServices 0x00000001152f9a6f GSEventRunModal + 161
28 UIKit 0x000000011105ac68 UIApplicationMain + 159
29 Keebin_development_1 0x000000010fc3fe5f main + 111
30 libdyld.dylib 0x000000011434d68d start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I can't seem to figure out where my problem is. I have created my CoffeeBrand+CoreDataClass.Swift and CoffeeBrand+CoreDataProperties.Swift with the editor-> create NSManaged Object Subclass and as other SO questions/answered has said with the codegen to manual/none.
The two classes mentioned:
import Foundation
import CoreData
#objc(CoffeeBrand)
public class CoffeeBrand: NSManagedObject {
}
and:
import Foundation
import CoreData
extension CoffeeBrand {
#nonobjc public class func fetchRequest() -> NSFetchRequest<CoffeeBrand> {
return NSFetchRequest<CoffeeBrand>(entityName: "CoffeeBrand");
}
#NSManaged public var brandName: String?
#NSManaged public var dataBaseId: Int64
#NSManaged public var id: Int64
#NSManaged public var numberOfCoffeesNeeded: Int32
}
Can someone see where I'm going wrong? Obviously it's in my for-loop but I don't know where/what/how to do it right.
Thanks in advance!

I figured out where I went wrong.
I changed let fetchRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest(entityName: "CoffeeBrand")
to
let fetchRequest: NSFetchRequest<NSManagedObject> = NSFetchRequest(entityName: "CoffeeBrand")
this way it is objects I fetch from the DB.
Then it was easy. Now my for-loop is simply:
for brands in searchResults {
coffeeBrandArray.append(brands)
}
callback(coffeeBrandArray)
} catch {
print("Error with request: \(error)")
}
}
And now everything works as it should.

Related

SwiftUI Crash in ForEach Loop

ScrollView(.horizontal, showsIndicators: false, content: {
LazyHGrid(rows: gridLayout2, alignment: .center, spacing: columnSpacing, pinnedViews: [], content: {
Section(
header: SectionView(rotateClockwise: false, headerText: "Premium Store"),
footer: SectionView(rotateClockwise: true, headerText: "Premium Store")) {
ForEach(premiumStoreItems) { item in
StoreItemView(storeItem: item)
}
}
}) //: LAZYHGRID
.frame(height: 200)
.padding(15)
})
The crash is occurring in the ForEach loop.
If I comment the ForEach and pass in 1 specific item from my array, it works fine. However I need to display all my items in my array.
I am not sure what to do here.
The following code works fine.
//ForEach(premiumStoreItems) { item in
StoreItemView(storeItem: premiumStoreItems[0])
//}
CRASH LOG (sorry I didnt know where to get it)
Application Specific Information:
Fatal error: each layout item may only occur once: file SwiftUI, line 0
------ FULL CRASH LOG
Process: AppExample001 [3525]
Path: /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/C93C2BE8-C23A-4813-9D6C-110E87786FFE/data/Containers/Bundle/Application/40562FF7-7B66-4BE4-915A-5A2A35AD3EC2/AppExample001.app/AppExample001
Identifier: AppExample001
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: launchd_sim [2488]
Responsible: SimulatorTrampoline [611]
User ID: 501
Date/Time: 2021-04-07 12:23:50.173 -0400
OS Version: macOS 11.2.3 (20D91)
Report Version: 12
Bridge OS Version: 5.2 (18P4347)
Anonymous UUID: 5A68DF80-DD1B-1132-4597-BBC26C334627
Time Awake Since Boot: 7000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [3525]
ID Vend/Dev
95f5 687f1002
Seconds Ago ID Type
6900.0 95f5 Attach
Application Specific Information:
Fatal error: each layout item may only occur once: file SwiftUI, line 0
CoreSimulator 732.18.6 - Device: iPhone SE (2nd generation) (C93C2BE8-C23A-4813-9D6C-110E87786FFE) - Runtime: iOS 14.4 (18D46) - DeviceType: iPhone SE (2nd generation)
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libswiftCore.dylib 0x00007fff2fc85004 assertionFailure(::file:line:flags:) + 532
1 com.apple.SwiftUI 0x00007fff572e9d24 ViewCache.commitPlacedChildren(from:to:) + 4020
2 com.apple.SwiftUI 0x00007fff571a1f16 specialized IncrementalChildPlacements.updateValue() + 1558
3 com.apple.SwiftUI 0x00007fff572be37f partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init(:) + 15
4 com.apple.AttributeGraph 0x00007fff4cd78723 AG::Graph::UpdateStack::update() + 505
5 com.apple.AttributeGraph 0x00007fff4cd78bb9 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 335
6 com.apple.AttributeGraph 0x00007fff4cd7d85f AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 523
7 com.apple.AttributeGraph 0x00007fff4cd8edc5 AGGraphGetValue + 203
8 com.apple.SwiftUI 0x00007fff572edac0 IncrementalPreference.children.getter + 48
9 com.apple.SwiftUI 0x00007fff572edb95 IncrementalPreference.value.getter + 85
10 com.apple.SwiftUI 0x00007fff572ede1c protocol witness for Rule.value.getter in conformance IncrementalPreference + 28
11 com.apple.AttributeGraph 0x00007fff4cd91907 dispatch thunk of Rule.value.getter + 7
12 com.apple.SwiftUI 0x00007fff570e9a18 implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init(_:) + 56
13 com.apple.AttributeGraph 0x00007fff4cd78723 AG::Graph::UpdateStack::update() + 505
14 com.apple.AttributeGraph 0x00007fff4cd78bb9 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 335
15 com.apple.AttributeGraph 0x00007fff4cd7d318 AG::Graph::value_ref(AG::AttributeID, AGSwiftMetadata const*, bool*) + 130
16 com.apple.AttributeGraph 0x00007fff4cd8ee13 AGGraphGetValue + 281
17 com.apple.SwiftUI 0x00007fff57987807 GraphHost.updatePreferences() + 39
18 com.apple.SwiftUI 0x00007fff57458cbf ViewGraph.updateOutputs(at:) + 95
19 com.apple.SwiftUI 0x00007fff573f04e4 specialized closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 1316
20 com.apple.SwiftUI 0x00007fff573ed28e specialized ViewRendererHost.render(interval:updateDisplayList:) + 366
21 com.apple.SwiftUI 0x00007fff57a59c0e specialized UIHostingController._render(seconds:) + 46
22 com.apple.dt.XCPreviewKit 0x000000010c117536 0x10c10a000 + 54582
23 com.apple.dt.XCPreviewKit 0x000000010c1246eb 0x10c10a000 + 108267
24 com.apple.dt.XCPreviewKit 0x000000010c11b91f 0x10c10a000 + 71967
25 com.apple.dt.XCPreviewKit 0x000000010c11bc08 0x10c10a000 + 72712
26 com.apple.dt.XCPreviewKit 0x000000010c11ddff 0x10c10a000 + 81407
27 com.apple.dt.XCPreviewKit 0x000000010c11c274 0x10c10a000 + 74356
28 com.apple.dt.XCPreviewKit 0x000000010c1134e3 0x10c10a000 + 38115
29 com.apple.dt.XCPreviewKit 0x000000010c112eee 0x10c10a000 + 36590
30 libdispatch.dylib 0x00007fff2010532f _dispatch_call_block_and_release + 12
31 libdispatch.dylib 0x00007fff20106508 _dispatch_client_callout + 8
32 libdispatch.dylib 0x00007fff20112ff7 dispatch_main_queue_callback_4CF + 1045
33 com.apple.CoreFoundation 0x00007fff2038fdbb CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
34 com.apple.CoreFoundation 0x00007fff2038a63e __CFRunLoopRun + 2685
35 com.apple.CoreFoundation 0x00007fff203896d6 CFRunLoopRunSpecific + 567
36 com.apple.GraphicsServices 0x00007fff2c257db3 GSEventRunModal + 139
37 com.apple.UIKitCore 0x00007fff24696cf7 -[UIApplication run] + 912
38 com.apple.UIKitCore 0x00007fff2469bba8 UIApplicationMain + 101
39 com.apple.SwiftUI 0x00007fff5791abc7 closure #1 in KitRendererCommon(:) + 119
40 com.apple.SwiftUI 0x00007fff5791ab3f runApp(:) + 143
41 com.apple.SwiftUI 0x00007fff5745212d static App.main() + 61
42 com.oneorangetree.AppExample001 0x000000010bfcaf4e static AppExample001App.$main() + 78
43 com.oneorangetree.AppExample001 0x000000010bfcafd4 main + 20
44 libdyld.dylib 0x00007fff2025a3e9 start + 1
ForEach is unable to identify the each item uniquely,
make sure your data model struct is confirm to identifiable protocol
try this on
ForEach(premiumStoreItems, id:\.self)
ForEach(premiumStoreItems, id:\.id) // if you've unique identifier with the name of "id"

Unusual Error appending new element to an array resulting in application crash

I am fetching a list of items from an API. This works fine. I have a local variable in my view controller such that upon successfully fetch of the items from API, I am reloading my table view.
Recently in the line where I am appending contents of the array from API to my local array variable, I am now getting a crash. I have research severally on SO with no success. I keep getting the thesame error
This is code causing the crash
Irrelevant API fetch code
if refresh {
self?.items = ticketItems
}
else {
self?.ticketItems.append(contentsOf:
ticketItems)
}
Usually, I should not get a crash when appending the contents of an array. This is weird to me. Please Find error message:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !CGSizeEqualToSize(size, CGSizeZero)'
*** First throw call stack:
(
0 CoreFoundation 0x0000000116bb86fb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x00000001157adac5 objc_exception_throw + 48
2 CoreFoundation 0x0000000116bb8482 +[NSException raise:format:arguments:] + 98
3 Foundation 0x000000010fe51927 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
4 UIKitCore 0x000000011e0f0399 -[_UIUpdateVisibleCellsContext addSize:forIndexPath:] + 385
5 UIKitCore 0x000000011e0e8643 -[UICollectionViewFlowLayout shouldInvalidateLayoutForPreferredLayoutAttributes:withOriginalAttributes:] + 409
6 UIKitCore 0x000000011e0a2f08 -[UICollectionView _checkForPreferredAttributesInView:originalAttributes:] + 559
7 UIKitCore 0x000000011e0a3c24 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 1596
8 UIKitCore 0x000000011e0a35e2 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 31
9 UIKitCore 0x000000011e0a8a8c -[UICollectionView _updateVisibleCellsNow:] + 6120
10 UIKitCore 0x000000011e0adbb6 -[UICollectionView layoutSubviews] + 365
11 UIKitCore 0x000000011ecf99c1 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1417
12 QuartzCore 0x0000000111cf7eae -[CALayer layoutSublayers] + 173
13 QuartzCore 0x0000000111cfcb88 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 396
14 QuartzCore 0x0000000111d08ee4 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 72
15 QuartzCore 0x0000000111c783aa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 328
16 QuartzCore 0x0000000111caf584 _ZN2CA11Transaction6commitEv + 608
17 QuartzCore 0x0000000111cafede _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
18 CoreFoundation 0x0000000116b1f0f7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
19 CoreFoundation 0x0000000116b195be __CFRunLoopDoObservers + 430
20 CoreFoundation 0x0000000116b19c31 __CFRunLoopRun + 1505
21 CoreFoundation 0x0000000116b19302 CFRunLoopRunSpecific + 626
22 GraphicsServices 0x000000011be162fe GSEventRunModal + 65
23 UIKitCore 0x000000011e82bba2 UIApplicationMain + 140
24 Sterling Bank App 0x000000010c1be211 main + 225
25 libdyld.dylib 0x0000000118307541 start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I was getting the exact error:
'Invalid parameter not satisfying: !CGSizeEqualToSize(size, CGSizeZero)'
It was just because I forgot to set translatesAutoresizingMaskIntoConstraints to false for a subview I was adding to cell's contentView...

Converting an array containing structure to json

I'm trying to convert an array into json but can't get it to work. It says the array is an invalid type to convert to json, but it's just an array of ints.
//These are for me to able to use time
let date = NSDate()
let calendar = NSCalendar.current
//This is the structure that my array will be filled with
struct Day
{
var week: Int?
var date: Int?
var month: Int?
var year: Int?
var weekday: Int?
}
//This is my array
var theArrayContainingAllTheUserData = [Day]()
var numberofloops = 0
//This is a loop that fills my array with data
while theArrayContainingAllTheUserData.count < 20
{
var theincreasingnumberofdays: NSDate {
return NSCalendar.current.date(byAdding: .day, value: numberofloops, to: NSDate() as Date)! as NSDate
}
let myCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)!
numberofloops=numberofloops+1
var ScoopDay = Day()
ScoopDay.week=Int(myCalendar.component(.weekOfYear, from: theincreasingnumberofdays as Date!))
ScoopDay.date=Int(myCalendar.component(.day, from: theincreasingnumberofdays as Date!))
ScoopDay.month=Int(myCalendar.component(.month, from: theincreasingnumberofdays as Date!))
ScoopDay.year=Int(myCalendar.component(.year, from: theincreasingnumberofdays as Date!))
ScoopDay.weekday=Int(myCalendar.component(.weekday, from: theincreasingnumberofdays as Date!))
theArrayContainingAllTheUserData.append(ScoopDay)
}
//And here is my failed attempt at converting it to json
do {
let jsonData = try JSONSerialization.data(withJSONObject: theArrayContainingAllTheUserData, options: JSONSerialization.WritingOptions.prettyPrinted)
} catch {
print(error.localizedDescription)
}
Getting Error:
2016-10-28 13:20:09.669 jsona arrayen[3284:332873] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (_SwiftValue)'
First throw call stack:
(
0 CoreFoundation 0x000000010840834b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000107e6921e objc_exception_throw + 48
2 CoreFoundation 0x0000000108471265 +[NSException raise:format:] + 197
3 Foundation 0x000000010795d284 _writeJSONValue + 668
4 Foundation 0x000000010795d6d9 ___writeJSONArray_block_invoke + 132
5 CoreFoundation 0x00000001083ae36f __NSArrayEnumerate + 607
6 Foundation 0x000000010795d3df _writeJSONArray + 330
7 Foundation 0x000000010795d204 _writeJSONValue + 540
8 Foundation 0x000000010795cf94 -[_NSJSONWriter dataWithRootObject:options:error:] + 124
9 Foundation 0x000000010795ce74 +[NSJSONSerialization dataWithJSONObject:options:error:] + 333
10 ??? 0x0000000116ddd3cb 0x0 + 4678603723
11 jsona arrayen 0x0000000107892620 main + 0
12 CoreFoundation 0x00000001083ad25c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
13 CoreFoundation 0x0000000108392304 __CFRunLoopDoBlocks + 356
14 CoreFoundation 0x0000000108391a75 __CFRunLoopRun + 901
15 CoreFoundation 0x0000000108391494 CFRunLoopRunSpecific + 420
16 GraphicsServices 0x000000010d796a6f GSEventRunModal + 161
17 UIKit 0x0000000108f3bf34 UIApplicationMain + 159
18 jsona arrayen 0x00000001078926e9 main + 201
19 libdyld.dylib 0x000000010b8e968d start + 1
20 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Swift: Read and write binary data (cookies) to disk?

Specifically I want the command line utility to write the data from NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies to a file and then read the data so I can later call NSHTTPCookieStorage.sharedHTTPCookieStorage().setCookie()
Here's the code I have so far.
if (Process.arguments.count >= 2 && Process.arguments[1] == "-deleteAll") {
for cookie in NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies! {
NSHTTPCookieStorage.sharedHTTPCookieStorage().deleteCookie(cookie as NSHTTPCookie)
}
} else if (Process.arguments.count >= 3 && Process.arguments[1] == "-restore") {
println("restore from file: " + Process.arguments[2])
} else if (Process.arguments.count >= 3 && Process.arguments[1] == "-export") {
println("export to file: " + Process.arguments[2])
}
The lines
for cookie in NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies! {
cookie.writeToFile("/Users/aaron/Documents/test.txt", options: nil, error: nil)
}
give me an error:
2014-12-30 20:20:46.564 Test[17423:424845] -[NSHTTPCookie writeToFile:options:error:]: unrecognized selector sent to instance 0x100511260
2014-12-30 20:20:46.579 Test[17423:424845] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSHTTPCookie writeToFile:options:error:]: unrecognized selector sent to instance 0x100511260'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff950fc64c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff97e556de objc_exception_throw + 43
2 CoreFoundation 0x00007fff950ff6bd -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff95046a84 ___forwarding___ + 1028
4 CoreFoundation 0x00007fff950465f8 _CF_forwarding_prep_0 + 120
5 Test 0x00000001001caa1f top_level_code + 991
6 Test 0x00000001001caa9a main + 42
7 libdyld.dylib 0x00007fff918fd5c9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I guess this is under the category of writing generic data to disk.

Xtify Datastore Richnotification db is Nil

I must say I've been seeing that your support team is terrific, batting many, many problems successfully. Kudos on heroic support.
Here's my little one.
I installed everything by the book, and ran the code on my iPhone 5, firmware 6.0.1. It's giving the following error: ERROR Creating data store. Datastore for richnotification db is nil. Below is the log. Also below is the last exception backtrace.
-[XLappMgr registerForPush] [Line 325] Attempt to register for push notifications...
Reachability Flag Status: WR t------ networkStatusForFlags
Succeeded registering for push notifications. Device token: <left out for security purposes, but valid.>
ERROR Creating data store. Datastore for richnotification db is nil
Last Exception Backtrace:
0 CoreFoundation 0x3972a3e2 __exceptionPreprocess + 158
1 libobjc.A.dylib 0x385b695e objc_exception_throw + 26
2 CoreFoundation 0x3972a302 +[NSException raise:format:] + 102
3 Foundation 0x39964f14 -[NSURL(NSURL) initFileURLWithPath:] + 72
4 Foundation 0x39964e3e +[NSURL(NSURL) fileURLWithPath:] + 38
5 Rabbit 0x00108acc -[XLDbMgr managedObjectModel] (XLDbMgr.m:74)
6 Rabbit 0x00108caa -[XLDbMgr createNewDatabase] (XLDbMgr.m:101)
7 Rabbit 0x00108b4c -[XLDbMgr persistentStoreCoordinator] (XLDbMgr.m:89)
8 Rabbit 0x001088f0 -[XLDbMgr managedObjectContext] (XLDbMgr.m:47)
9 Rabbit 0x0010883c +[XLDbMgr getDBMgr] (XLDbMgr.m:23)
10 Rabbit 0x000fba10 -[AppDetailsMgr init] (AppDetailsMgr.m:33)
11 Rabbit 0x000fb97c +[AppDetailsMgr get] (AppDetailsMgr.m:26)
12 Rabbit 0x00110fd2 -[XLServerMgr sendProviderDeviceToken] (XLServerMgr.m:94)
13 Rabbit 0x00110d0c -[XLServerMgr initWithReg:] (XLServerMgr.m:64)
14 Rabbit 0x001000d6 -[XLappMgr registerWithXtify:] (XLappMgr.m:118)
15 Rabbit 0x0008073e -[AppDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:] (AppDelegate.m:54)
16 UIKit 0x38c5f7ee _UIXXRemoteNotificationRegistrationSucceeded + 146
17 UIKit 0x38c60278 _XRemoteNotificationRegistrationSucceeded + 112
18 AppSupport 0x36a9940c migHelperRecievePortCallout + 188
19 CoreFoundation 0x396ff3e2 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
20 CoreFoundation 0x396ff386 __CFRunLoopDoSource1 + 134
21 CoreFoundation 0x396fe20a __CFRunLoopRun + 1378
22 CoreFoundation 0x39671238 CFRunLoopRunSpecific + 352
23 CoreFoundation 0x396710c4 CFRunLoopRunInMode + 100
24 GraphicsServices 0x369aa336 GSEventRunModal + 70
25 UIKit 0x38a6128c UIApplicationMain + 1116
26 Rabbit 0x0008055a main (main.m:16)
27 Rabbit 0x000804fc start + 36
I did ANE for Adobe AIR App and I had to solve this problem for a long time, but finally I realized the reason: The resource files that are in the XtifyLib / XtifyPush.embeddedframework / XtifyPush.framework / Versions / A / Resources / must always be added to the project in my case, with ANE it should be in the folder iPhone-ARM, because ADT moves them to the top-level directory - it is there where it is necessary

Resources