it's been a while I'm working on a project and I just discovered that I have to use the Core Data framework.
The issue is that I did'nt tick the Use Core Data case when I created the project and I don't know what I have to modify to make it work.
I think this is mostly in the AppDelegate but I'm not sure.
Thank you very much guys.
Elbattore
Related
I am using the following code:
let context = appDelegate.persistentContainer.viewContext
When this line is run, not only does the app crash, xcode also crashes if the device is in debug mode linked to xcode.
I have de-commented out my code line by line and this is the line where it seems to be having problems.
Does anyone know how to fix this?
Thanks.
Was this code working previously for you, and now it has suddenly started crashing? When this has happened to me, it's always been because I made a change to my xcdatamodel without properly migrating it.
The quick fix is to rename your MyAppName.xcdatamodeld file. ie, change it to MyAppName2.xcdatamodeld. Then be sure to change it wherever it appears in your code, such as strings:
var coreDataStack = CoreDataStack(modelName: "MyAppName2")
Once you've got it working again, be sure to look up automatic lightweight migration of Core Data. Basically, any time you want to make changes to Core Data entities, you have to create a new version of your data model first. See this link for more info. iPhone Core Data "Automatic Lightweight Migration"
if you changed in model with Xcode 9.2 please make sure target of that model is added to project in Xcode 9.2 we have to add as target manually
I'm an newbie in ios programming. I'll use swift and realm for my app. But I'm not getting how'll I create an DB and table in Realm.
I'm studying raywenderlich and realm.io.
But here nothing is so much clear to me. I've placed
1) realm.framework
under project's general tab's embedded binaries section. Now what to do.
Any help would be appreciated.
You can refer to this steps https://realm.io/docs/swift/latest/#prerequisites
But I will advise you, as others have mention to use dependency manager such as cocoa pods. Save you a lot of headaches
https://cocoapods.org
I will start developing a new project for iOS. I am unsure for now if I should use core data in this project, or not. I will find out along the way, while developing (most likely with some coaching help).
Now my noob question is: Should I, while creating my new project, already check the option 'use core data'? Or shouldnt I?
Basically my question is: What is more difficult, removing core data when I checked the option and I will not been using it after all? Or adding core data when I did not check the option and I will be using it after all?
I have found it is not super difficult to add after:Implement CoreData into an existing project using Swift
But still, it seems like alot of hassle, so I now ask u!
Thanks for the answer in advance
It doesn't matter. Starting with Core Data just prepares the core data code in the app delegate and makes an empty model file, both of which are
1) easy to create yourself, or
2) copy from a new empty project started with core data later when you need it.
And if you already have it in your project, but you don't use it, it is also no problem. I found that almost all projects need core data after a while, so I usually just let it create it from the start.
Xcode just allows you to check using coredata to prepare already a coredata for you project.
BUt it is very simple to add or remove it later.JUst simple as File>create or File delete.
In a words don't worry about creating in the begining or later.
All day, I have been cleaning up an old project of mine.
I have a lot of needless features that I want to get rid of to avoid the app from getting to cramped (including an intro screen that I would like to redesign).
Anyways, I've created a new project and I've been transferring over bits of code, piece by piece to keep everything clean.
All of the code seems to be in the same place as my previous project, however, I am now receiving numerous Semantic Issue (occasional ARC Semantic Issue) errors upon building the app.
Is there any stupid mistake I am making that someone else has encountered themselves? Or am I doing something frantically wrong. Newbie here, I apologize in advance.
If anyone is willing to take a deeper look into the issue, I'd be happy to send the project. :)
You don't seem to have imported the Core Data headers into your app delegate.
#import <CoreData/CoreData.h>
I have an existing database on SQLite3.
How I can import this database into XCode and work with data?
Is it possible to work with SQLite3 without using Core Data?
I have never encountered this problem and in other forums I I didn't understand.
Thank you.
SQLite is available for iOS and OSX. The C API library is provided by Apple. You don't need core data. Just use the C API to work with the sqlite database or use an Objective-C wrapper such as FMDB.
Just add your existing database to the project like any other resource file.
Under iOS, if you need to write to the database you will need to copy the database file at runtime from the app's bundle to a writable folder. Do this the 1st time the app runs.
I know this may not answer your question, but I think you can find this really helpful..
this is a framework I found on the internet to work with sqlite databases..
https://github.com/enormego/egodatabase
GL HF