core-data

How can I get the input argument type of a selector?

I'm trying to write a generic XML to Core Data parser using libxml2. Since I have control over both, the XML elements correspond exactly to the objects and the attributes to the properties of the objects. This is all fine and everything works well, except when the attributes are of a type other than NSString. I realize that selectors k...

How to model an n-to-n relationship in Objective-C?

I am trying to model an n-to-n relationship in Objective-C. Suppose I have two entities: Movie and Theater. A Movie has an array of Theaters and a Theater has an array of Movies. How do I do this in Objective-C to 1) get the relationship correct and 2) make sure memory is managed correctly. ...

Core Data Fetching Objects That Are in Relationship to another object

I want to fetch objects B which has a to-many relationship with object A (ie. A -->> B). I already have A in memory. I know I could get a NSSet of the B objects from A, but would it be better to make a fetch request of the B objects (especially if I want to sort sections by date in a UITableView)? How would I make such a request that on...

iPhone and Core Data

Hi, I need some understanding about using Core Data. Can it be used to save and retrieve all of my objects used in my program? Is there any simple example demonstrating this ? I am having hard time finding one online. Thanks for any replies. ...

Patterns for accessing remote data with Core Data?

I am trying to write a Core Data application for the iPhone that uses an external data source. I'm not really using Core Data to persist my objects but rather for the object life-cycle management. I have a pretty good idea on how to use Core Data for local data, but have run into a few issues with remote data. I'll just use Flickr's API ...

Objective-C error: Property 'active' is a scalar type on class 'Routine'. Cannot generate a getter method for it.

I'm getting the above error when the following runs in the iphone simulator (3.0 OS): @interface Routine : NSManagedObject { } @property (nonatomic) BOOL active; @implementation Routine @dynamic active @end As you can see, I'm subclassing NSManagedObject because I'm using Core Data. In my data model, "active" is an option attribute...

iPhone Core Data fetching date manipulations

Hi, I'm new to developing for the iPhone and I'm using Core Data for my data management. My managed objects have a property called creationDate and I need to have a list of all distinct dates that are in the database. To reduce the overhead I set [fetchRequest setPropertiesToFetch:[NSArray arrayWithObject:@"creationDate"]]; because th...

Rearranging UITableView with Core Data

I'm trying to find a code sample that shows how to handle moving/rearranging cells in a tableView when the cell uses a fetchedResultsController (i.e. in conjunction with Core Data). I'm getting the moveRowAtIndexPath: call to my data source, but I can't find the right combination of black magic to get the table/data to recognize the cha...

Efficient approach to do search using SearchBar,SearchDisplayController and UITableView.

I want to do postcode search using SearchBar,SearchDisplayController and UITableView. I am thinking of doing it using CoreData, but still I want to know if anyone has some efficient idea to do the same. And database have 15000 row, so is it advisable to port sqlite file into application and use core data API to fetch the results. Than...

How to use @sum with CoreData

I have Week model that has Day as child objects. There is "days" relation property in Week model to access all associated Day objects. Day model has duration property. How can I figure out sum of day's durations for specified Week object? It would be great to have code example how to create a predicate object with @sum function. Also i...

SQLite + Core Data Vs. File system on Iphone App that shows photos. What's more performant?

Hello, I have an application where the user will navigate around a set of photographs. What's best in terms of performance for this scenario, SQLite + Core DATA for persisting the photos as NSData objects or having the photos as png files directly on the file system? thanks. ...

Core Data, NSPredicate and to-many key

I have a Core Data model in which a Task entity includes an optional to-many relationship excludedOccurrences. One of the properties of excludedOccurrences is start, which is an NSDate object. The ExcludedOccurrence entity has an inverse mandatory to-one relationship to the Task entity. In order to fetch tasks for a specified day, I nee...

Coredata on iPhone, setFetchBatchSize & setPropertiesToFetch in one Request

Hi, I'm writing a coredata based iPhone app that displays recipes. To improve performance, when displaying them in a TableView, I want to enable batching (-setFetchBatchSize:) and fetching only the "name" attribute (-setPropertiesToFetch:). When I turn on both, it doesn't work and the list is empty. As soon as I comment out one of the l...

Storing large (e.g. image/movie) files in Core Data on the iPhone

Looking at the Apple iPhone Core Data Recipes sample app, they store image files in core data objects, which is not something I would normally think would be wise. Now I'm going to be also stories captured video on the 3GS. The question is: is it wise to store images, and then furthermore, movies, in Core Data on the iPhone? In addition...

Is a Persistent Store a requirement for Core Data on the iPhone?

Hey guys, I'm looking to use Core Data within my iPhone app. The app doesn't really need to store the data that is used, but it needs to be managed and queryable. Can Core Data be used for datasets that exist purely in memory and are not persisted to the disk? ...

Trying to add a index to the iPhoneCoreDataRecipes sample code

I've been trying to add a index to the iPhoneCoreDataRecipes sample code and I'm having no luck. Any ideas? ...

Core Data Fetched Properties to rank connectivity between Objects

I want to rank how strongly connected instances of Entity A are to other instances or Entity A are in my graph.I only need to do this for the n most recently viewed entities. I describe relations between two instances of Entity A by means of another Entity B. This is because I need to describe each relationship. I was considering using ...

Core Data simple relationship in code

Hi, I am a cocoa newbie trying to create an iPhone app including Core Data. My problem is this: I have a little app running now with a single entity called Playlist that I display in a table view and can add and delete entries in. I have these in my PlayerAppDelegate: playlistManagedObjectModel playlistListManagedObjectContext play...

Where should I keep Core Data fetches and convenience methods?

I've got a number of convenience methods that perform fetches for my Core Data entities. For example, a method that returns currently-active activities, or a time interval between two completed activities, or a default client if there is one. I also have convenience methods to initialize and add entities with various attributes. I have ...

What is the best way to store document specific settings in a Core Data Document?

I'm using a NSPersistantDocument backed by Core Data in my application. Each document has a number of settings that are only relevant to that document. For example the document needs to hold the unique ID of an Address Book Group, to update it at a later date. The way I'm thinking of approaching this is to have another model, DocumentS...