FAQ Database Discussion Community


Core Data not saving in distribution build

ios,core-data,nsmanagedobjectcontext,testflight
I have a very strange problem where Core Data works fine in development (debug) builds, but in distribution (release) builds distributed over TestFlight, my NSManagedObjectContext objects are not saving correctly. I'm observing two issues: NSManagedObjectContextDidSaveNotification doesn't get sent when a context is saved. Data doesn't persist between launches. What could...

iPad SearchViewController crash _PFArray objectAtIndex beyond bounds

ios,objective-c,ipad,core-data,uisearchresultscontroller
I'm working on the iPad version of my application and I'm facing a strange problem. Here's the structure of the application: UISplitViewController ->MasterViewController -->NavigationController --->TableViewController ---->PrototypeCells --->SearchDisplayController ->DetailViewController -->NavigationController --->TableViewController ---->StaticCells Basically, the application is displaying like 40 000 rows with CoreData and fetchResultController on the MasterView. Users can search...

Core Data - check if relationship is nil

ios,objective-c,core-data
I'm trying to check if a relationship object in a returned query is nil. When I print the relationship it literally says nil in the log but checking against nil does not work. If I then check against a property in the object I get a crash because that just...

What is the Difference between Action Methods of MagicalRecord in iOS

ios,core-data,magicalrecord,actionmethod
Please explain the Difference between below mentioned methods. - (void)save: - (void)saveOnlySelfAndWait; - (void)saveToPersistentStoreAndWait; Note: Some one have posted answer of this question but i am not satisfied with that answer so can anyone please post me proper and simple answer....

How do I compare the value of password stored in CoreData with user input?

swift,core-data,ios8,xcode6
This is the code for login page where I want to compare input with stored data. import UIKit import CoreData class ViewController: UIViewController { @IBOutlet weak var userName: UITextField! @IBOutlet weak var passwordText: UITextField! @IBAction func login(sender: AnyObject) { var appdel : AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate) var context :...

Method for moving rows with NSFetchedResultsController and its delegate not working

ios,swift,core-data,tableview,nsfetchedresultscontrolle
I've been trying to follow this tutorial for rearranging rows in a table view while using NSFetchedResultsController and NSFetchedResultsController delegate, but my project is extremely buggy. What happens is that when I try rearranging a row and drop it, the rows are randomised (probably not randomised, but I can't see...

Property 'package_number_7' not found on object of type 'User *' after Lightweight Migration

ios,objective-c,xcode,core-data,xcode6
I have a CoreData based application. In my data model I've changed data model just by add to User entity row "package_number_7" and use Lightwight Migration (just adjust appdelegate) .. Now when I want to use this "package_number_7" in fetch request it's not working. here is sample code from viewcontroller...

Undefined symbols for architecture i386 with EncryptedCoreData

ios,swift,core-data,cocoapods,pod
I use EncryptedCoreData to encrypt CoreData. Integrate it with pod ( pod 'EncryptedCoreData', :git => 'https://github.com/project-imas/encrypted-core-data.git'), in Bridging-Header - file I include: #import <EncryptedCoreData/EncryptedStore.h> , but I have such error: Undefined symbols for architecture i386: "_OBJC_CLASS_$_EncryptedStore", referenced from: __TMaCSo14EncryptedStore in AppDelegate.o ld: symbol(s) not found for architecture i386 clang: error:...

How best to subclass NSManagedObject to provide a set of core methods

ios,objective-c,xcode,core-data,refactoring
I am working on a typical IOS app that implements a Core Data model and I am using XCode to generate the base set of NSManagedObjects for each entity in the model. Typical Example, nothing special here: // // ContactKey.h #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @class ContactAttribute; @interface ContactKey : NSManagedObject...

Core Data sort descriptor with NSDate, iOS with Swift

ios,swift,core-data
I am trying to filter core data objects depending on a date attribute. This is my current code: func getFetchedResultController(selectedEntity: NSString){ let appDelegate : AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let managedObjectContext: NSManagedObjectContext = appDelegate.managedObjectContext! let fetchRequest = NSFetchRequest() let entity = NSEntityDescription.entityForName(selectedEntity as String, inManagedObjectContext: managedObjectContext) fetchRequest.entity = entity fetchRequest.fetchBatchSize...

NSPredicate filter part of array

ios,swift,core-data,nspredicate
I just began coding and I've chosen swift. I have a CoreData database and I use a predicate to display parts of it. It works fine to find a complete expression. What can I do to search in the datafield Strasse.name just a part of a string like "*way". Here...

Save NSUndoManager transactions one by one

ios,core-data,nsmanagedobjectcontext,nsundomanager
I need to save changes not only locally into Core Data, but on server too. My concern is, in my case user can do bunch of interaction in a short time. Between interaction there is not enough time to receive success message returned from server. So either I lock the...

CoreData :NSFetchedResultsController one to many to many to many relationship

ios,objective-c,core-data,nspredicate
I working on app were I using core data and the core data object is is show below: Giving theaterName and genreName I want to show the actorsName. Anyone know of a way to build a NSPredicate to do that?...

Cannot configure RestKit with CoreData

ios,objective-c,core-data,restkit
I did setup my project to use RestKit and CoreData: added CoreData framework in 'Link binary with libraries' and "pod 'RestKit', '~> 0.24.0'" to my Podfile. Everything looked fine until I tried to use RKObjectManager's method managedObjectRequestOperationWithRequest:managedObjectContext:success:failure: Xcode gives me the following error: No visible @interface for 'RKObjectManager' declares the...

Change database of Live App without Data Lose

ios,iphone,sqlite,core-data
I want to update the database of my existing app(for new version) which is live on the app store. So I need to delete my existing database before using app or I can change the name of the database. After it If data exists in my old database I have...

Should I reset context from its own thread?

ios,multithreading,core-data
Can I write mainMOC.reset() or should I nest it like here: mainMOC.performBlockAndWait({ mainMOC.reset() }) I want to perform it from an arbitrary thread....

One to Many remove Object not deleting object on many entity

ios,core-data
I have one entity called Activity (one) and Game (many). I setup the delete rule as Cascade for the "game" relationships on the Activity entity and Nullify (*** more on this later) for the "activity" relationships on the Game entity. If I delete an Activity object, then all Game objects...

Core data model not finding auto-generated entity classes after upgrading to XCode 6.3.2 (using Objective-C rather than Swift)

ios,objective-c,core-data,xcode6
Today I upgraded to XCode 6.3.2. I have a single XCode project that generates a number of different apps. Each app is a different compile target. All apps use the same core data model. There are 4 versions of the core data model. The lastest one is the current one....

Core Data: Which record loads by default in core data if you do not specify which one?

ios,core-data
I have a static table for settings where I want to pull some stuff from an entity in Core Data. The use case does not lend itself to a table of records as you usually see. Rather each row of the static table is really a field related to the...

How can I convert Int32 to Int in Swift?

swift,core-data,int,type-conversion
It should be easy but I can only find the reverse conversion. How can I convert Int32 to Int in Swift? Unless the problem is different? I have a value stored in Core Data and I want to return it as an Int. Here is the code I am using,...

Core Data One-To-Many Relationship Memory Usage

ios,core-data,memory-management,one-to-many
I am using core data where I have object A which has a one-to-many relationship with object B. In practice there could be 1000s of Bs related to one A. My concern is that when I define the inverse of the one-to-many relationship, object A will have a NSSet containing...

Core Data - Swift - Catch “keypath not found in entity” error

ios,swift,core-data,error-handling
I am trying to catch an error when I execute a FetchRequest with a wrong/inexistent Key/Keypath but the app still crashes. This is how I created the NSPredicate: let pred = NSPredicate(format: "(\("WRONGKEY") = %@)", equalTo) let request = NSFetchRequest() request.predicate = pred request.entity = MyEntityDescription (WRONGKEY is a parameter...

Saving a Managed Object with a To One type

ios,swift,core-data
I am new to iOS development and I am trying to get my head around using multiple managed objects. For example the test app has a two entities one for Folder, and another for Planner. It is a To One type so for every folder there is a planner. Planner...

Why my NSFetchedResultsController loads all rows?

ios,objective-c,core-data,nsfetchedresultscontrolle,nsfetchrequest
I have a NSFetchedResultsController used to display data in a table view (22117 rows). The fetchBatchSize is set to 20 on the fetchRequest. It works as expected: only 20 rows are fully populated when the table view is loaded. SQL statements: 2015-06-12 17:59:55.526 BoulderFinder[2228:1220755] CoreData: sql: SELECT 0, t0.Z_PK FROM...

I am trying to use Core Data and load a table view with its contents in order and in sections

ios,swift,core-data,tableview
I get it to load, I get the sections to load, but I cant get the cells in each section to load correctly. It restarts from the beginning in each section effectively duplicating each cell. My entity name is Customer and it holds the following attributes. firstName, lastName, phoneNumber,email, notes,...

Core Data to-one relationship returns NULL

ios,core-data,nspredicate,nsmanagedobject,relationships
The Batting.team relationship doesn't always save properly and returns null sometimes About 100 'Team' NSManagedObjects are saved and can log their attributes as expected. Then about 15000 'Batting' NSManagedObjects are saved and all attributes log correctly except for the relationship. I want the Batting.team relationship to point to the Team...

IOS Use Core Data Only in Specific Parts of an app

ios,api,core-data
I'm new to Core Data and trying to use it for persisting objects for offline support in an app communicating with JSON Back-end. I was using NSObjects for my models and now use NSManagedObjects. I only need to save these server objects in a few parts of the app, and...

Creating a Mapping Model by code instead of XCode

ios,objective-c,xcode,core-data
I have read the Core Data documentation about migration. However, I see only how to create a mapping model in XCode. How can I do the same only by code?

swift crash when altering UITableViewCells during update

ios,uitableview,swift,core-data
I'm trying to fix a bug where my app is crashing when tapping on a cell while it's trying to fetch new data for the UITableView. Here's how my data-flow is set up. When the viewController is loaded, I load data from CoreData, and fill my UITableView with that data...

Does executeFetchRequest:error: return the same object instance every time?

ios,objective-c,core-data
I'm new to core data and had a query. If I call executeFetchRequest:error: to retrieve an entity from the context, and store this entity in a variable called A, and I repeat the process and store it the next time in a variable called B, will A and B refer...

two arrays from NSFetchedResultsController swift

ios,swift,core-data,nsfetchedresultscontrolle
I have a table that is populated using data from CoreData and NSFetchedResultsController. It populates two sections using one attribute having a boolean value. But I want to have the data in each section into two arrays for further processing. Is there a way to save the data in the...

NSFetchedResultsController swift sections

ios,swift,core-data,nsfetchedresultscontrolle,sections
I have a table view that takes data from a CoreData entity with 3 fields. firstName: String, lastName: String and done:NSNumber (which is a UISwitch that can be turned ON or OFF). I want to populate the table with the first and last names but first section is with names...

RestKit throws NSInternalInconsistencyException upon PUT request

ios,swift,core-data,restkit
My app crashes with an NSInternalInconsistencyException, when issuing a PUT request in the following manner: Download profile information through HTTP GET Update the profile on the client Upload the changes through HTTP PUT Parse the body of the PUT response body again The error I get 2015-05-27 17:27:17.796 XYZ[17093:2526798] ***...

How to prevent swift CoreData crash on uninitialized data

ios,uitableview,swift,core-data
I have a UITableView that stores data in a CoreData entity. The problem is that when retrieving the data in the UITableViewCell, if I try to access cells that has not been accessed yet. The app will crash. How do I prevent that from happening? I receive the error that...

Swift - Storing and retrieving data [closed]

ios,swift,core-data,nsfetchrequest,store-data
So, my doubt is this: how can I store some data (strings and images, for example) in the application and then, later, retrieve these data properly? I've read some stuff about it but I didn't quite understand (call me whatever you want u.u). My idea is that I have some...

NSFetchedResultsController section grouping by relation

ios,swift,core-data
So I have a Core Data entity which I am trying to display in a table view using an NSFetchedResultsController. The relevant model attributes looks something like this: Post parentPost (OtM relation) childPosts (inverse of parentPost) rootParent (OtM relation, points to the top of the tree) allChildren (inverse of rootParent,...

Sorting the results of an NSFetchRequest of objects that implement compare:

objective-c,cocoa,core-data,nsfetchrequest,nssortdescriptor
I have a NSManagedObject subclass that implements the compare: message. I want to retrieve these objects and sort them using this compare method, but apparently I have to provide a key for the NSSortDescriptor. I don't want to provide any key, as the object itself already knows how to compare...

Calling method on object in NSPredicate with Core Data

ios,core-data,nspredicate
I have a 'position' entity with a to-many relationship to 'employee's. I want to use NSPredicate to do something like this [position.employees containsObject:meEmployee] There is a call to perform NSPredicate with block, but sadly it can't be used with CoreData. How can I do this?...

MainPageCollectionViewConrtoller _setViewDelegate:]: unrecognized selector sent to instance 0x7faa7ae39160

ios,swift,core-data,uicollectionview,uicollectionviewcell
I'm writing a simple program that by now it only should show a simple uicollectionview. cells contain a label and an image view.The images stored in CoreData.There is also a code for times that no data is available. But it's giving me this Error: 2015-06-16 23:03:15.694 What Can I Wear[16167:2033274]...

NSManagedObject in temporary context gets faulted

swift,core-data
I've got a list of elements where editing/creation is possible, I do this in a new context and save it only if the user presses save. My problem is now that when I'd like to handle the object to an other view controller, the properties are all nil, i.e. the...

Core Data properties based upon relationships returning NULL

core-data,nspredicate,nsmanagedobject,nsmanagedobjectcontext,relationships
I have a Core Data data model such as I want to display the Teams.name associated with each Batting object in my UITableViewCell. When I try to access batting.teams.name it returns NULL. My opening view controller has a string passed in then creates a new viewController with NSPredicate based from...

Is it possible to do fetch and save in Private context,Without notifying anything to main context.?

ios,core-data
I'm having a doubt about coredata: Is it possible to do fetch and save in Private context,Without notifying anything to main context.?I saw in many example and tutorials that In every save or fetch finally we are end up with main context. Why it is necessary? If i call save...

iOS - Confused about when to use Core Data in my app

ios,database,swift,caching,core-data
I understand that Core Data is essentially a self-contained local database, but I'm not sure if I should be using it in my app or not. Basically, it would be more for caching purposes if anything, since I retrieve all of my content from a web server database. Regardless, I...

Slow UISearchDisplayController with Core Data

ios,iphone,core-data,nsfetchedresultscontrolle,uisearchdisplaycontroller
I have a TableViewController displaying like 40 000 rows from Core Data with NSFetchedResultsController. I implemented a live search with a UISearchDisplayController (support for IOS 7). It's working but typing on the keyboard when searching is very slow... I'd really appreciate if someone could point me to the right direction...

Core Data inputting numbers > 1.0 error

ios,cocoa,cocoa-touch,core-data,nsnumber
I'm working on coding a journal application which uses core data to store amongst other things, theme data (what the app looks like) - this was working until recently when I changed quite a lot of code. I'm now coming across an issue when trying to import a float into...

Get fields from NSArray with CoreData content

ios,xcode,swift,core-data
i have a table in coredata with some fields, i can get the count of records but i can´t get the values from each field, now i have this code: var request:NSFetchRequest = NSFetchRequest(entityName: "Radar") //my table in coredata let appDelegate:AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate) let context:NSManagedObjectContext = appDelegate.managedObjectContext! request.returnsObjectsAsFaults...

Crash: Swift, Adding a new Entity on an already existing Core Data

ios,swift,core-data
I have a Core Data, called TaskManager, On this CoreData at the moment only one Entity, Task: Task got severals attributes: import Foundation import CoreData @objc(Task) class Task: NSManagedObject { @NSManaged var context: String @NSManaged var date: String @NSManaged var detail: String @NSManaged var id: String @NSManaged var responsable: String...

Functions for fetching and saving data in an NSManagedObject class

ios,swift,core-data
I would like to implement saving and fetching of core data directly in a class definition. But when i try to instance it i get the following error: "CoreData: error: Failed to call designated initialiser on NSManagedObject class 'User'". Can anyone tell me what i'm doing wrong? The entity has...

Core Data: Save edits to persistent store

ios,core-data
I think I know the answer to this but not sure. And I don't have a good way to check as it is not yet working properly, so am therefore asking question. To display a user profile stored in core data's persistent store i.e. sqllite database, I fetch an object...

Implementing Core Data validation methods in Swift

ios,swift,core-data
How do I implement the Core Data validation methods (these take the form validate<Key>:error: in Obj-C) in Swift? In Obj-C, I would write the following in my model class to validate the name attribute: -(BOOL)validateName:(id *)name error:(NSError **)outError { } And I could cast the name to NSString by doing:...

NSFetchRequest to retrieve Every Student's Maximum Test Score for Every Subject in CoreData Entity

ios,uitableview,core-data,nspredicate
I have a CoreData Entity with multiple performance records in races of differing length. I want to pull the best performance for each athlete in each race and then put the results in an CoreData Table View. Here is the hack that I have come up with to accomplish this....

how to have existing data in coredata ENTITY before the app launches

ios,core-data,settings,default-database
In my iOS app - I have something called settings where I set the priority for X , Y ,Z ; eg: X = 30, Y = 60 , Z = 80. which have some default value (X=50,Y=50 and Z =50) for the first time and untill user changes it...

Unable to query for date using NSPredicate in Swift

ios,swift,core-data,nspredicate
I'm trying to make a fetch for dates later than a specific date. My predicate is as follows: NSPredicate(format: "date > \(currentDate)") When I executed the fetch request I caught an exception: 'Unable to parse the format string "date > 2015-07-08 03:00:00 +0000"' I thought I could make a query...

How do I call the CoreData proxy framework from WatchKit Extension?

ios,iphone,swift,core-data,watchkit
I have set up an iPhone app in Xcode and added a Cocoa-Touch iOS framework to handle the data as per apple's suggestion. Basically, I've done everything in this tutorial: http://www.telerik.com/blogs/send-data-to-apple-watch-with-core-data-and-telerik-ui-for-ios-in-swift On the iPhone side it works fine calling the functions however if I try to call the exact same...

change NSManagedObject parent entity in another version

ios,core-data,nsmanagedobject,core-data-migration,nsmanagedobjectmodel
Is there any good way to change parent entity of an NSManagedObject in another version? Lets say on model version 1.1 I got: anObject - with no parent entity in version 1.2 i want to make it inherit from object - a parent class that already exist in version 1.1...

Swift CoreData compare string with entities

ios,swift,core-data
I am browsing a NSArray and sending what I get on a Core Data, like this: let json2:NSArray = NSJSONSerialization.JSONObjectWithData(data.dataUsingEncoding(NSUTF8StringEncoding)!, options: NSJSONReadingOptions.MutableContainers, error: &error) as! [NSArray] for dict in json2 { var apps = [String]() //Creation du lien vers la base SQLite let entityDescription = NSEntityDescription.entityForName("Task", inManagedObjectContext: self.context!) let nTask...

Exception thrown at predicate

ios,core-data
I don't know why am I getting an error on that piece of code: //fecha y hora actual let date = NSDate() let calendar = NSCalendar.currentCalendar() let components = calendar.components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay | .CalendarUnitHour | .CalendarUnitMinute, fromDate: date) let hour = components.hour let minutes = components.minute let year...

iOS App groups - shared CoreData fails to open

ios,objective-c,core-data,watchkit,ios-app-group
I have an app with a CoreData database and access it using UIManagedDocument. To share the data with the Watchkit app, I'm moving the database to a shared App Group. The store is created correctly it seems, but after that it often becomes impossible to access it: the UIManagedDocument keeps...

How do I access the attribute of a one to many relationship and pass to another tableview?

uitableview,core-data,nsfetchedresultscontrolle,nsmanagedobject
So I have two entities in CoreData (A and B). A has many Bs and B can only belong to one A. I have managed to display A on a tableview and when I tap a cell, it should segue to another tableview controller that displays the list of Bs....

Am I approaching concurrency right?

ios,objective-c,core-data,concurrency
I was wondering if someone could point me in the right direction about whether or not I am using concurrency correctly. I find that currently, the code is very unwieldy and almost unintuitive. For the purposes of my demonstration, please note the CoreData architecture is as described by Marcus Zarra...

Retrieving Entities from Core Data: Printing properties gives me incomplete/unwanted results?

objective-c,core-data,printing,attributes
I've recently decided to move all my application data from plists to Core Data. This was pretty straightforward. I had a class with a couple properties I would read all my plist info to using a dictionary. This was mimicked by creating an entity with the same exact attributes. I...

Error adding CoreData to existing project

ios,objective-c,cocoa,core-data
Here is code #import "AppDelegate.h" #import "Crittercism.h" @interface AppDelegate () @end @implementation AppDelegate @synthesize managedObjectContext = _managedObjectContext; @synthesize managedObjectModel = _managedObjectModel; @synthesize persistentStoreCoordinator = _persistentStoreCoordinator; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { id context = self.managedObjectContext; return YES; } #pragma mark - Core Data stack - (NSURL *)applicationDocumentsDirectory { // The...

xCode 6.3.2 Crash [UIViewController .cxx_destruct]

objective-c,xcode,core-data,memory-management
I have converted an application written in Objective-C, previously using SQL, now changed to CoreData. Issue I identify so far is when I changed NSObject to NSManagedObject in only one of class I am getting this stupid crash in ViewController after View is completely dismissed: [self dismissViewControllerAnimated:YES completion:nil]; Control stopped...

Testing Core Data in Watch extension on the simulator

iphone,xcode,core-data,ios-simulator,apple-watch
I'm creating an apple watch app. I have created my shared framework, and the app extension. It all actually works pretty well, but when I try to query objects from my Core Data DB, i get only empty arrays. I have already created the app groups, and made sure the...

Core Data and a UIActivityViewController

objective-c,core-data,nsmutablearray,nsarray,uiactivityviewcontroller
I have my app that is using core data to persist data. I have a UIActivityViewController setup on my main VC. Everything is working as I expect it to. My question is when you go to grab items from a core data model, how do you have it give you...

Default NSTimeInterval used by CoreData

ios,core-data,nsdate,nstimeinterval
NSDate value is returned by CloudKit. Which representation will system choose, when I am storing date in Core Data as NSTimeInterval? I know NSTimeInterval stores number of seconds since some specific reference date. But which reference date will be choosen here? mo.setValue(record.creationDate, forKey: "creationDate") Latter on I have to compare...

Ensembles in iOS swift

ios,swift,core-data,ensembles
I would like to use Drew McCormack's Ensembles from github to relieve my current iOS/swift/coredata/iCloud induced headache. All of the Ensembles examples are in Objective-C. I have it as a Framework in my project, but being a weekend coder, I can't extrapolate how to use it from the ObjC example...

Save Image as local file or as binary data IOS

ios,uitableview,swift,core-data
For this question there are many answers but i did not understand for some specific difference between them so i will post what i need and then question. About My Project: i have image which has an effect added Gaussian blur and things like this, memory is optimized well. when...

Full CoreData uploading (backup) to iCloud Drive and restore if need

ios,xcode,core-data,icloud,cloudkit
My project is CoreData-based application. Is it enough to upload sqlite-file to CloudDrive for restoring data when need? Is there any tutorials how to implement it?

Convert ABRecordID to NSNumber always -1

ios,swift,core-data,nsnumber,abpeoplepickerview
I am trying to save an ABRecordID of an existing contact from the Address Book into Core Data. I have an Int32 defined in my model, but in order to save my object there I need to convert the ABRecordID (which is an Int32) into an NSNumber Here is my...

iOS Core Data concurrency and other background queues

ios,multithreading,core-data,dispatch-async
I am working on a iOS SDK that involves concurrency of Core data. User case is: App calls SDK's api on the main queue with callback Core data worker MOC is NSPrivateQueueConcurrencyType. It needs to create model in its queue and save to persistence. Then, SDK needs to do some...

IOS/Xcode/Objective C:Load one record from Core Data without loading table first

ios,core-data,executefetchrequest
For a profile screen, I would like to load the equivalent of a detail page from Core Data without having to load a table first. I have an entity/ table of multiple users in core data. But I'm only interested in pulling the profile data on one of them, the...

Collection View automatically handles large amounts of records?

ios,swift,core-data,ios8,uicollectionview
I have a variable that holds a collection of records from Core Data. Sometimes it can be thousands of records. If I feed this variable into a collection view, does it automatically handle large amount? What I am hoping is that the collection is lazy loaded into the variable from...

Would this fill the child context with only TemporaryIDs?

ios,objective-c,core-data,concurrency
I was wondering if someone would be able to answer this question. I am currently building my application using the CoreData stack as described by Marcus Zarra in his blog http://martiancraft.com/blog/2015/03/core-data-stack/. He describes the usage of managedObjectContext as the Single Source Of Truth where all insertions/updates/deletions should be done on...

Core Data, with Swift. Entity query

ios,swift,core-data
I am presently making my first steps using Core Data, with Swift. Even though I have quite a bit of experience with Core Data, I have close to none with Swift. Here is what I want to do: make a function which is going to compute the number of records...

Delete row in TableView and remove the core data - iOS / Swift

swift,core-data,xcode6,delete-row
I am having an issue with my swift app. I am trying to implement the swipe feature that will prompt the user with the "DELETE" option. As of right now my code only allows me to swipe but the delete button is not being generated. I am currently using Xcode...

swift - CoreData inManagedObjectContext is nil

ios,swift,core-data
I am trying to save data to coredata, but I got "unexpectedly found nil while unwrapping an Optional value" error from insertIntoManagedObjectContext. I double check the naming of my entity (Article), attributes (articleID, isFavorite). But I couldnt found the cause of the error. func saveArticleAsFav(articleID: Int){ let isFav = true...

UISearchController shows incorrect results

ios,xcode,swift,core-data,uisearchcontroller
I have application with UITableViewController, two UIViewController and Core Data. I want to make UISearchController for the first time. I looked on the other questions by this theme, but I have working incorrect UISearchController. When I write into searchBar, it give incorrect results. And I don't know how show them...

How to use reflection with Core Data and Swift

ios,swift,core-data,reflection
I'm trying to use reflection in Swift with Core Data entities, but when I execute the following code, my reflected var has only a reference for a super class, it didn't have a reference for any of it's attributes. func printProperties() { let mirror = reflect(self) for var i =...

Magical Record, cannot save an object: contextDidSave == NO, error = nil

ios,objective-c,iphone,core-data,magicalrecord
I'm trying to persist new entities: - (void)updateStorageWithQuizzess:(NSArray *)quizzess completion:(void(^)(NSArray *quizzess, BOOL succes, NSError *error))completion { NSMutableArray *mutableArray = [NSMutableArray array]; [Quiz MR_truncateAll]; [[NSManagedObjectContext MR_context] MR_saveWithBlock:^(NSManagedObjectContext *localContext) { for (NSDictionary *dictionary in quizzess) { Quiz *quiz = [Quiz MR_createEntity]; [quiz fromDictionary:dictionary]; [mutableArray addObject:quiz]; } } completion:^(BOOL contextDidSave, NSError *error) {...

How can I sort an array from Core Data using a stored integer attribute?

ios,arrays,swift,uitableview,core-data
I am trying to get the moveRowAtIndexPath method to work using Core Data. My program is user-driven meaning that the user updates the data repeatedly and is basically a table view that displays the name of an Entity. Each Entity has two attributes: a name and an integer that represents...

swift - CoreData

ios,swift,core-data
I have a custom NSManagedObject: import Foundation import CoreData @objc(Article) class Article: NSManagedObject { @NSManaged var articleID: String @NSManaged var isFavorite: Bool init(entity: NSEntityDescription, insertIntoManagedObjectContext context: NSManagedObjectContext?, articleID: String, isFavorite: Bool) { super.init(entity: entity, insertIntoManagedObjectContext: context) self.articleID = articleID self.isFavorite = isFavorite } override init(entity: NSEntityDescription, insertIntoManagedObjectContext context:...

Core Data Scalar error only on some devices

ios,swift,core-data
I've been testing primarily using iPhone 6, 6 plus, and iPad. Just tried my app today on the iPhone 5 simulator, and got a Core Data error. CoreData: error: Property 'setId:' is a scalar type on class 'AppName.EntityName' that does not match its Entity's property's scalar type. Dynamically generated accessors...

How can I populate a tableView with an NSSet? (swift)

ios,uitableview,swift,core-data
I have a Person Class in tableView1, then in TableView2, the user adds brands to associate with the person. My fetch request is trying to get back the person they selected and populate the tableView's rows with the associated brands of that person, but I'm stuck here: override func tableView(tableView:...

How to change attribute type in xcdatamodel?

ios,xcode,core-data,xcdatamodel
I'm a newbie that is assigned to gigantic project. I have found a minor bug that needs fixing but i don't know exactly how. Ok here it is. issueNumber attribute in Xcode's core data model is set to Integer 64. I need to change it to String, so the bug...

this class is not key value coding-compliant for the key itemname

ios,objective-c,iphone,core-data,ios7
What I am trying to do is take the text that is in my uitextfield called editItemField and write the value in the NSString called toDoItemName to my core data model with the attribute named itemname. Im getting the above error. My core data model has one attribute named itemname...

Which is a better way: retrieve images from AWS S3 or download it and store locally in a temp folder to be displayed?

objective-c,core-data,amazon-web-services,amazon-s3,awss3transfermanager
Problem: Retrieve image from S3 and load into UIButton. I'm currently doing my research on this issue and can't seem to make up my mind. Which is a better way to do it in terms of performance and security issue? Also, do I need to do caching or store these...

NSManagedObject subclass' category equivalent in Swift?

ios,swift,core-data
I just started Swift and usually in Objective-C I create a category for each one of my NSManagedObject subclasses so the category isn't erased each time I have to generate my subclass. Moreover, it can simplify the creation of CoreData objects, especially when populated by data coming from a JSON....

Swift code with multiple NSDateFormatter - optimization

ios,swift,core-data,nsdateformatter
For swift learning purposes, I'm work on personal Core Data project. So far everything is working, but I cannot figure out how to optimize the code. By optimization I mean only visual optimization, the performance is different story and is too early for me. In the class below I'm using...

Getting objects from to-many relationship in Swift Core Data

ios,swift,core-data,one-to-many
I have been having some difficulties revolving around using to-many relationships in Core Data with Swift. My data model What I am trying to do is to use an instance of a Country and then display all of the Contacts that are citizens of that country. As I have been...

Convert NSValue to NSData and back again, with the correct type

objective-c,core-data,nsdata,nsvalue
I would like to be able to convert an objective-c object, such as an NSArray or UIImage into an NSData object, which I can then use to write to disk. I first converted them to an NSValue, which I then planned on converting to NSData. This question provided part of...

Deleting core data objects in a table view

ios,swift,core-data
I am new to Swift and I am following a tutorial about making a gesture-driven app. As in the tutorial, a table view is populated from array objects. There is a function to remove an item from the table view when the user drags the cell to the left. func...

Store Core Data Sqlite in NSLibraryDirectory or NSApplicationSupportDirectory?

ios,sqlite,core-data,path,sync
What is the difference between NSLibraryDirectory and NSApplicationSupportDirectory? Which one is the best place to store the Core Data .sqlite file if I am planning on using a syncing service? I currently store my .sqlite file in NSLibraryDirectory. If NSApplicationSupportDirectory turns out to be the better choice, how will changing...

Syntax for loop ManagedObject insertion in swift

ios,swift,core-data
On the process of exploring Core Data with Swift I have the following function working, as a test: func insertObject (entityName:String) { var newItem = NSEntityDescription.insertNewObjectForEntityForName(entityName, inManagedObjectContext:managedObjectContext!) as! EventList let now = NSDate() newItem.date = now newItem.eventDescription = “Whatever Anniversary" } This seems to work, but to make my function...

Updating Core Data Model using two separate View Controllers

ios,objective-c,uitableview,core-data
I originally had my app setup to store one line items in a single entity within my core data model. I have since decided to change this to allow the main uitableview to simply list the name of each item and then when you tap on an item you can...

UIActivityIndicatorView (spinner) wont show or stop after loading remote json data

json,swift,core-data
I’m working on an app with Core Data and after local data is preloaded, it fires off the loading of json data from S3 url. So, i’d like to show the spinner because for some reason it takes an average of 8 seconds to show data in(blank frozen tableview), so...

Crashing after lightweight Core Data migration

ios,core-data
I am trying to master Code Data migration, its going to be important for supporting my app. The reason I need the migration is to preserve data. My app is used for psychological research and collection reaction time data. I have a game session and every game session has ordered...

App crash after hammering button

multithreading,osx,swift,cocoa,core-data
In my app the user has to press a button to generate data which is created and processed in a dedicated thread and afterwards stored via Core Data. The button is immediately being disabled after it's pressed and is only again enabled after the data was saved via Core Data....

Passing data - Swift

ios,swift,core-data,store-data
In my app, I'm building a recipe list for foods. The first view controller has a tableview that stores the recipe's name and photo. This name and photo are set in the second view controller via segue. Here it is: As you can see, the second view controller has a...

Storing images to CoreData - Swift

ios,image,swift,core-data,nsdata
In my code I managed to save a textLabel with CoreData but I can't seem to properly save the image. I've read some tutorials and I know I have to convert it to NSData. But how do I do it? Thanks in advance!...