core-data

Calculating columns with Core Data like SQL

Hey, I am sorting stores to get the closest stores. Furthermore I want to know how far away this shop is. The SQL query would look like this: select *, 6371 * 2 * ATAN2(SQRT(POWER(SIN((RADIANS(?) - RADIANS(latitude))/2),2) + COS(RADIANS(latitude)) * COS(RADIANS(?)) * POWER(SIN((RADIANS(?) - RADIANS(longitude))/2),2)), SQRT(1-POWER(SIN...

How to correctly setup a NSPredicate for a to-many relationship when using Core Data ?

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

How to Sort an NSMutableArray of Managed Objects through an object graph

I'm new to Apple's iPhone 3.0 SDK support of Core Data and I'm relatively new to iPhone development. My question is on slightly more "complex" sorting than is covered in the docs. I suspect that I am making an incorrect, fundamental assumption. How can I sort a pre-fetched collection of managed objects by a property contained several l...

Custom UID data type for CoreData

The CoreData documentation says "You can sometimes benefit from creating your own unique ID (UUID) property which can be defined and set for newly inserted objects. This allows you to efficiently locate specific objects using predicates (though before a save operation new objects can be found only in their original context)." What shoul...

Renaming Core Data class

Hi, I have an application that uses CoreData. I previously had a class named Marker which was linked to the Marker entity in Core Data. I renamed the Marker class to CoreDataMarker. So I created a new .xcdatamodel file with the new class name for the entity. Then I created a .xcmappingmodel and selected the old and the new .xcdatamode...

Creating a unique id for a Core Data program on the iPhone

I am fairly new at programming in Objective-C, having been a windows programmer since I was a kid. I am falling in LOVE with it. I am, however, having a bit of trouble figuring out this Core Data stuff. How do I create a new entry with a unique ID? In SQL I would just declare one field as an autoincrement field. I'm not seeing anyth...

Core Data Leaking Memory?

I keep seeing what appears to be a memory leak - but I can't tell what to do. It looks like a memory leak in Core Data. I can see the LAST method I explicitly invoke in Objective-C, but I'm not creating any object there. I'm saving something and Core Data is leaking memory according to Leaks. Am I reading this incorrectly? ...

iphone tabbar where to load data?

Hi, I have two tabbar items(views) that use the same data, whats the best solution for getting the data? Make two fetch request for the same data in each view controller. Make one fetch request in appDelegate, and use sharedApplication to get to the data in appDelegate. I can use KVO and notifications to notify the views if the data h...

How to properly configure NSFetchedResultsController

I am placing an NSFetchedResultsController into my code so I get that nice automatic sectioning of my table view data. So I am running a test to make sure everything works properly. I have a single Book entity in my persistent store. I will first perform the fetch the old way, then I will try to use NSFetchedResultsController. The diffe...

iphone tab bar controller and core data.

Ok bit of a newbie type question. I want to use Core Data, together with Tab and Navigation controllers. In XCode if I create a Navigation Based Application I get the option to choose Core Data. Whereas If I create a Tab Bar Application I don't get the choice. I understand that Tab Bars display view controllers so it kinda makes sen...

NSManagedObject subclass outside of managed object as a normal object

Hi all, I have an entity object Country with country name and country code. It is a subclass of NSManagedObject and I am using it with core data model to store its value to a persistent store. I have a place where the same Country object will used as a normal object i.e. I will use it to store some temporary country name. For that I ...

How to remove CoreData's objects from memory?

I use CoreData to store image data that user took from iPhone's Camera. Over time, the memory consumed by these objects keep increasing, but I don't know how to clear those objects from the memory. How should this be done? ...

Is there a way to retrieve a set or array of keys for a given NSManagedObject?

For any given NSManagedObject, is there any method to return a set or array of keys (attribute names) for that particular NSManagedObject? I've tried looking around in NSObject & NSManagedObject docs but found nothing. Something that functions like NSDictionary 'allKeys' would be what I need, ie. myArrayOfKeys = [myDict allKeys] I pr...

Can I make NSManagedObject into a singleton?

I have a NSManagedObject object filled with data I want to use in multiple view controllers. Can I make this object into a singleton and use it in multiple view controllers? Or should I use a different approach? ...

Can I encode a subclass of NSManagedObject?

This is for an iPhone App, but I don't think that really matters. I need to send a custom object (which is managed by Core Data) over bluetooth using the iPhone's GameKit. Normally, I would just use an NSKeyedArchiver to package up the object as a data object and ship it over the line, then unarchive the object and I'm done. Of course, I...

Why is this Core Data example crashing?

I have a model where I have a Person entity and a Picture entity. In my Picture entity I have a property that is a relationship to a Person. I would like to have an example about how to add a Picture to a Person because what I did doesn't work. -(BOOL)savePicture:(NSString *)urlPicture:(Person *)person{ SettingsSingleton *userSettings ...

core data or sqlite or plist files

Hello, I have a situation where I need to store the data in local (iphone) and the same data will be in the web server to be accessed by other users (like sending messages) . For the web server part I am not worrying, I created all the tables and relations. but I am worrying about Iphone side data storage and sync both sides correctly....

Get Primary Key Value From SQLite database using Core Data in Iphone

Hi, I want to use core data in my application with back end Sqlite store. But I need the Primary key (auto inc Integer) value after an insert which I want to send this primary key value to a web server. Is there any way to get the primary key of the record from sqlite database through the core data feature ? I don't want the unique I...

Core Data: Returning properties depending on a value

Hi! can anyone guide me how to create a fetch request that will query an entity and returns any properties that qualify my criteria. Here's what I have. I have an entity that has 35 properties, all are in types of float. What I need was to see all properties of the entity which values was <= zero. I know how to return the values of the...

UITableView's reloadData isn't resorting the cells

I have a UITableView that implements NSFetchedResultsControllerDelegate. When I tap a cell, I load another viewcontroller which allows me to edit an entity represented by the tablecells. When I'm done editing, it sends a message to the UITableViewController which does a [self.tableview reloadData]; My problem is that reloadData doesn'...