Search Results

Search found 146 results on 6 pages for 'nsmanagedobject'.

Page 5/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • objective-C : Reset tableview loaded with feltching objects (core data)

    - by the1nz4ne
    hi, i have a tableview application loaded with core data feltching objects and i wanna know if it is possible to reset the table with a simple button. Thanks code to add an object : NSManagedObjectContext *context = [fetchedResultsController managedObjectContext]; NSEntityDescription *entity = [[fetchedResultsController fetchRequest] entity]; NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context]; [newManagedObject setValue:string forKey:@"timeStamp"]; my code to delete (one) object: NSManagedObjectContext *context = [fetchedResultsController managedObjectContext]; [context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]]; i want a button that reset the tableview and delete everything thanks

    Read the article

  • How to properly use CoreData validation & error framework ?

    - by Xav
    I've created a model in Xcode, and for various attributes I have minimum & maximum values defined and that are enforced by coreData at runtime. I'm using NSManagedObject validateValue:forKey:error to check for user input values. I was a bit disappointed to see that the localized error message is not specific, and I get a "The operation couldn't be completed. (Cocoa error 1620)" for too small values and a "The operation couldn't be completed. (Cocoa error 1610)" for too large values. It's written in the coreData documentation that "you can localize most aspects of a managed object model, including entity and property names and error messages". Unfortunately it's not very detailed on how you implement it for error messages. So How do you customize error message ? How do you localize them ? Is it possible to customize it in a way where it will mentioned the reference value ex: "Value should be lower than %@" or "Value should be higher than %@" ?

    Read the article

  • Left with extra UITableViewCell after re-ordering

    - by Mark F
    After going into Edit mode, moving a cell, and leaving edit mode, i am left with one extra cell sitting on top of its duplicate cell while still in edit mode. The problem has to be somewhere in here: - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { NSMutableArray *array = [[fetchedResultsController fetchedObjects] mutableCopy]; id objectToMove = [[array objectAtIndex:sourceIndexPath.row] retain]; [array removeObjectAtIndex:sourceIndexPath.row]; [array insertObject:objectToMove atIndex:destinationIndexPath.row]; [objectToMove release]; for (int i=0; i<[array count]; i++) { [(NSManagedObject *)[array objectAtIndex:i] setValue:[NSNumber numberWithInt:i] forKey:@"userOrder"]; } [array release]; } Any guidance greatly appreciated!

    Read the article

  • How Do I create a synchronous version of NSURLConnection

    - by quinn
    I am using NSURLConnection inside of an NSIncrementalStore to synchronize my NSManagedObject with rest based web service built in Rails. I am aware of +sendSynchronousRequest:returningResponse:error but my understanding is that will not allow me to access such things as the HTTP response status code which I will need to properly handle the response, my understanding is sendSynchronousRequest returns the data if it responds in the 200 range and fails if it doesn't and doesn't really give you much more than that. I'm assuming I will somehow have to block the current method call after the NSURLConnection is instantiated and unblock it after NSURLConnection's delegate sets some value that can be returned by the blocked method. I'm assuming this will involve some combination of NSLock and NSThread but I really don't know where to start with this, any help will be greatly appreciated, thank you.

    Read the article

  • How to manually manage Core Data relationships when deleting

    - by Simon
    I have a Core Data entity, which contains a relationship to another entity. Under certain circumstances, I need to delete the managed objects in the relationship, and at other times no action needs to be taken. I have the Delete Rule on the entity is No Action because of this manual management. The problem I have is, where is the best place to enforce these rules? I cannot see any suitable messages to override on NSManagedObject (something that might notify the object it has been deleted and should clear up its relationships). I would rather not do it higher up in the application logic, because the entity objects can get deleted from array controllers and at different points in the applications, making it necessary to stuff relationship update code at all those levels.

    Read the article

  • unrecognized selector sent to instance

    - by iamsmug
    My app works fine in the simulator but when I run it on my phone I get this error: 2010-04-05 21:32:45.119 Top Banana[119:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[MethodViewController setReferringObject:]: unrecognized selector sent to instance 0x16e930' It happens here: -(void)method { [UIView beginAnimations:@"View Flip" context:nil]; [UIView setAnimationDuration:0.50]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; MethodViewController *methodViewController = [[MethodViewController alloc] initWithNibName:@"MethodViewController" bundle:0]; NSManagedObject *selectedObject = self.referringObject; methodViewController.referringObject = selectedObject; [self.navigationController pushViewController:methodViewController animated:NO]; methodViewController.title = @"Method"; [UIView commitAnimations]; [MethodViewController release]; } It crashes on this line: methodViewController.referringObject = selectedObject; Not sure how to resolve this as it works in the simulator, I'm sure it is fairly basic to fix, any help will be appreciated.

    Read the article

  • Couldn't I just pass an copied string to an Core Data property?

    - by dontWatchMyProfile
    The docs say: The default implementation does not copy attribute values. If the attribute value may be mutable and implements the NSCopying protocol (as is the case with NSString, for example), you can copy the value in a custom accessor to help preserve encapsulation (for example, in the case where an instance of NSMutableString is passed as a value). So instead of getting into trouble and inconvenience with overwriting accessors in my NSManagedObject subclass, couldn't I simply do something like this? myManagedObject.firstName = [[firstNameMutableStr copy] autorelease]; This would have the exact same effect, or not? The dynamic implementation would retain that anyways ... so.... why not the easy way?

    Read the article

  • Is there an difference between transient properties defined in the data model, or in the custom subc

    - by mystify
    I was reading that setting the value of a transient property always results in marking the managed object as "dirty". However, what I don't get is this: If I make a subclass of NSManagedObject and use some extra properties which I don't need to be persistet, how does Core Data know about them and how can it mark the object as dirty when I access these? Again, they're not defined in the data model, so Core Data has no really good hint that they are there. Or does Core Data use some kind of introspection to analyze my custom class and figure out what properties I have in there?

    Read the article

  • How to separate model and view with Core Data?

    - by andrewebling
    I have a subclass of UIView which draws itself based on data held in a corresponding model class, which is a subclass of NSManagedObject. The problem is, some fields in the data model (e.g. the position of the view) are already held in the view (i.e. the frame property in this case). I then have a data duplication/synchronization problem to solve. To complicate matters further, the view needs to update in response to changes made to the data model and the data model needs to be updated in responses made to the view (e.g. the user dragging it to a new location). What's the best way to solve this? Using KVO and references in both directions? Or is there a better approach?

    Read the article

  • CoreData Model Objects for API

    - by theiOSguy
    I am using CoreData in my application. I want to abstract out all the CoreData related stuff as an API so that the consume can use the API instead of directly using CoreData and its generated model objects. CoreData generates the managed objects model as following @interface Person : NSManagedObject @end I want to define my API for example MyAPI and it has a function called as createPerson:(Person*)p; So the consumer of this createPerson API needs to create a Person data object (like POJO in java world) and invoke this API. But I cannot create Person object using Person *p = [Person alloc] init] because the designated initializer for this Person model created by CoreData does not allow this type of creation. So should I define corresponding user facing data object may be PersonDO and this API should take that instead to carry the data into the API implementation? Is my approach right? Any expert advise if design the API this way is a good design pattern?

    Read the article

  • How to speed up saving a UIImagePickerController image from the camera to the filesystem via UIImagePNGRepresentation()?

    - by kazuhito0000
    I'm making an applications that let users take a photo and show them both in thumbnail and photo viewer. I have NSManagedObject class called photo and photo has a method that takes UIImage and converts it to PNG using UIImagePNGRepresentation() and saves it to filesystem. After this operation, resize the image to thumbnail size and save it. The problem here is UIImagePNGRepresentation() and conversion of image size seems to be really slow and I don't know if this is a right way to do it. Tell me if anyone know the best way to accomplish what I want to do. Thank you in advance.

    Read the article

  • Can I add a custom method to Core Data-generated classes?

    - by Andy
    I've got a couple of Core Data-generated class files that I'd like to add custom methods to. I don't need to add any instance variables. How can I do this? I tried adding a category of methods: // ContactMethods.h (my category on Core Data-generated "Contact" class) #import "Contact.h" @interface Contact (ContactMethods) -(NSString*)displayName; @end ... // ContactMethods.m #import "ContactMethods.h" @implementation Contact (ContactMethods) -(NSString*)displayName { return @"Some Name"; // this is test code } @end This doesn't work, though. I get a compiler message that "-NSManagedObject may not respond to 'displayName' " and sure enough, when I run the app, I don't get "Some Name" where I should be seeing it.

    Read the article

  • NSManagedObjectID into NSData

    - by papr
    I found this wonderful NSManagedObjectID. This would be very good for referencing an Entity/NSManagedObject/NSEntityDescription, right? Let's get an ID from an entity: NSEntityDescription *entity = [self newEntity]; NSManagedObjectID *objID = [entity objectID]; So... any idea how to get this objID into a string? Or better: NSData. Actually something to be able to save it to the NSUserDefaults. ;-) Btw: NSFetchRequest doesn't want to work in my case. I use an modified version of this example: answer of an old question.

    Read the article

  • MVC - Cocoa interface - Cocoa Design pattern book

    - by Idan
    So I started reading this book: http://www.amazon.com/Cocoa-Design-Patterns-Erik-Buck/dp/0321535022 On chapter 2 it explains about the MVC design pattern and gives and example which I need some clarification to. The simple example shows a view with the following fields: hourlyRate, WorkHours, Standarthours , salary. The example is devided into 3 parts : View - contains some text fiels and a table (the table contains a list of employees' data). Controller - comprised of NSArrayController class (contains an array of MyEmployee) Model - MyEmployee class which describes an employee. MyEmployee class has one method which return the salary according to the calculation logic, and attributes in accordance with the view UI controls. MyEmployee inherits from NSManagedObject. Few things i'm not sure of : 1. Inside the MyEmplpyee class implemenation file, the calculation method gets the class attributes using sentence like " [[self valueForKey:@"hourlyRate"] floatValue];" Howevern, inside the header there is no data member named hourlyRate or any of the view fields. I'm not quite sure how does it work, and how it gets the value from the right view field. (does it have to be the same name as the field name in the view). maybe the conncetion is made somehow using the Interface builder and was not shown in the book ? and more important: 2. how does it seperate the view from the model ? let's say ,as the book implies might happen, I decide one day to remove one of the fields in the view. as far as I understand, that means changing the way the salary method works in MyEmplpyee (cause we have one field less) , and removing one attribute from the same calss. So how is that separate the View from the Model if changing one reflect on the other ? I guess I get something wrong... Any comments ? Thanks

    Read the article

  • Removing and adding persistent stores to a core data application

    - by mkko
    I'm using core data on an iPhone application. I have multiple persisntent stores that I'm switching from one to another so that only one of the stores can be active at the time. I have one managed object context and the different persistent stores are similar in data format (sqlite) and share the same managed object model. I'm importing the data to each persistent store from a respective XML file. For the first import everything works fine, but after I remove the imported data (the persistent store and the physical file) and then re-import, core data gives me an error: *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'The NSManagedObject with ID:0x3c14e00 <x-coredata://6D14F11E-2EA7-4141-9BE8-53747DE6FCC6/Book/p2> has been invalidated.' This error comes from the save: of NSManagedObjectContext. Before re-importing, i'm removing the persistent store from the persistent store coordinator and removing the physical file, so everything should be as if re-importing was done for the first time. Alos, the objects in managed object context are removed and the context is sent the reset: message (I don't know if this is actually needed). Could some one help me out here? How should the persistent store be switched? I'm basically using the same logic as tutored here: http://blog.sallarp.com/iphone-core-data-uitableview-drill-down/ Thanks in advance.

    Read the article

  • Add objects in relationship not work using MagicalRecord saveWithBlock

    - by yong ho
    The code to perform a save block: [MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) { for (NSDictionary *stockDict in objects) { NSString *name = stockDict[@"name"]; Stock *stock = [Stock MR_createInContext:localContext]; stock.name = name; NSArray *categories = stockDict[@"categories"]; if ([categories count] > 0) { for (NSDictionary *categoryObject in categories) { NSString *categoryId = categoryObject[@"_id"]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"categoryId == %@", categoryId]; NSArray *matches = [StockCategory MR_findAllWithPredicate:predicate inContext:localContext]; NSLog(@"%@", matches); if ([matches count] > 0) { StockCategory *cat = [matches objectAtIndex:0]; [stock addCategoriesObject:cat]; } } } } } completion:^(BOOL success, NSError *error) { }]; The Stock Model: @class StockCategory; @interface Stock : NSManagedObject @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) NSSet *categories; @end @interface Stock (CoreDataGeneratedAccessors) - (void)addCategoriesObject:(StockCategory *)value; - (void)removeCategoriesObject:(StockCategory *)value; - (void)addCategories:(NSSet *)values; - (void)removeCategories:(NSSet *)values; @end The json look like this: [ { "name": "iPad mini ", "categories": [ { "name": "iPad", "_id": "538c655fae9b3e1502fc5c9e", "__v": 0, "createdDate": "2014-06-02T11:51:59.433Z" } ], }, { "name": "iPad Air ", "categories": [ { "name": "iPad", "_id": "538c655fae9b3e1502fc5c9e", "__v": 0, "createdDate": "2014-06-02T11:51:59.433Z" } ], } ] Open the core data pro, You can see only stock with the name of "iPad air" has it's categories saved. I just can't figure out why. You can see in the saveWithBlock part, I first find in the context for the same _id as in json, and then add the category object in the relationship. It's working, but not all of them. Why is that?

    Read the article

  • Core-data: when accessing a relationship, the count method on NSSet fails

    - by lordsandwich
    I'm trying to access a relationship (one to many) programatically. My Data model contains an NSManagedEntity called language (with a two string attributes) with a relationship to an entity called WordCategory (one-to-many). I use an NSFetchRequest to get all the Language entities. that works fine. I get the valueForKey for the relationship and that works fine. I can work with its objects. However, when I try to send the message count to the NSSet that stores the WordCategory objects I get a In other words, this line works: NSLog(@"word category count %@",[[wordCategory anyObject] valueForKey:@"name"]); This one doesn't: NSLog(@"word category count %@",[wordCategory count] I get a the message: EXC_BAD_ACCESS in the debugger. Here's the rest of the code: NSManagedObjectContext *moc = [myAppDelegate managedObjectContext]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@"Language" inManagedObjectContext:moc]]; NSError *error = nil; NSArray *results = [moc executeFetchRequest:request error: &error]; if (error) { [NSApp presentError:error]; return; } NSManagedObject *obj = [results objectAtIndex:0]; NSSet *wordCategory = [obj valueForKey:@"category"]; NSLog(@"word category count %@",[wordCategory count]); I'll appreciate any light than anybody can shed in this mystery. Thanks for your help!

    Read the article

  • Core Data - Entity Relationships Not Working as expected

    - by slimms
    I have set up my data model in xcode like so EntityA AttA1 AttA2 EntityB AttB1 AttB2 AttB3 I then set up the relationships EntityA Name: rlpToEntityB Destination: EntityB Inverse: rlpToEntityA To Many: Checked EntityB Name: rlpToEntityA Destination: EntityA Inverse: rlpToEntityB To Many: UnChecked i.e. relationship between the two where Each one of EntityA can have many EntityB's It is my understanding that if i fetch a subset of EntityB's I can then retrieve the values for the related EntityA's. I have this working so that i can retrieve the EntityB values using NSManagedObject *objMO = [fetchedResultsController objectAtIndexPath:indexPath]; strValueFromEntityB = [objMO valueForKey:@"AttB1"]; However, if I try to retrieve a related value from EntityA by doing the following strValueFromEntityA = [objMO valueForKey:@"AttA1"]; I get the error "The entity EntityB is not Key value coding-compliant for the key Atta1" Not surprisingly i suppose if i switch things around to fetch from EntityA i cannot access attributes of EntityB So it appears the defined relationshipare being ignored. Can anyone spot what i am doing wrong? I confess im very new to iPhone programming and especially to Core Data so please go easy on me and provide verbose explanations or point me in the direction a specific resource. I have downloaded the apple sample apps (Core Data Books, Top Songs and recipes) but I still can't work this out. Thanks in advance, Nev.

    Read the article

  • Why is a CoreData forceFetch required after a delete on the iPad but not the iPhone?

    - by alyoshak
    When the following code is run on the iPhone the count of fetched objects after the delete is one less than before the delete. But on the iPad the count remains the same. This inconsistency was causing a crash on the iPad because elsewhere in the code, soon after the delete, fetchedObjects is called and the calling code, trusting the count, attempts access to the just-deleted object's properties, resulting in a NSObjectInaccessibleException error (see below). A fix has been to use that commented-out call to performFetch, which when executed makes the second call to fetchObjects yield the same result as on the iPhone without it. My question is: Why is the iPad producing different results than the iPhone? This is the second of these differences that I've discovered and posted recently. -(NSError*)deleteObject:(NSManagedObject*)mo; { NSLog(@"\n\nNum objects in store before delete: %i\n\n", [[self.fetchedResultsController fetchedObjects] count]); [self.managedObjectContext deleteObject:mo]; // Save the context. NSError *error = nil; if (![self.managedObjectContext save:&error]) { } // [self.fetchedResultsController performFetch:&error]; // force a fetch NSLog(@"\n\nNum objects in store after delete (and save): %i\n\n", [[self.fetchedResultsController fetchedObjects] count]); return error; } (The full NSObjectInaccessibleException is: "Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0x1dcf90 <x-coredata://DC02B10D-555A-4AB8-8BC4-F419C4982794/Blueprint/p"

    Read the article

  • iPhone Core Data does not refresh table

    - by Brian515
    Hi all, I'm trying to write an application with Core Data, and I have been able to successfully read and write to the core data database. However, if I write to the database in one view controller, my other view controllers will not see the change until the app is closed then reopened again. This is really frustrating. I'm not entirely sure how to get the refresh - (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag method to work. How do I get a reference to my managed object? Anyways, here's the code I'm using to read the data back. This is in the viewDidLoad method. NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Website" inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"siteName" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [sortDescriptor release]; [sortDescriptors release]; NSError *error = nil; NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; if(mutableFetchResults == nil) { //Handle the error } [self setNewsTitlesArray:mutableFetchResults]; [mutableFetchResults release]; [request release]; [newsSourcesTableView reloadData]; Thanks for help in advance!

    Read the article

  • Objective-C Getter Memory Management

    - by Marian André
    I'm fairly new to Objective-C and am not sure how to correctly deal with memory management in the following scenario: I have a Core Data Entity with a to-many relationship for the key "children". In order to access the children as an array, sorted by the column "position", I wrote the model class this way: @interface AbstractItem : NSManagedObject { NSArray * arrangedChildren; } @property (nonatomic, retain) NSSet * children; @property (nonatomic, retain) NSNumber * position; @property (nonatomic, retain) NSArray * arrangedChildren; @end @implementation AbstractItem @dynamic children; @dynamic position; @synthesize arrangedChildren; - (NSArray*)arrangedChildren { NSArray* unarrangedChildren = [[self.children allObjects] retain]; NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"position" ascending:YES]; [arrangedChildren release]; arrangedChildren = [unarrangedChildren sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; [sortDescriptor release]; [unarrangedChildren release]; return [arrangedChildren retain]; } @end I'm not sure whether or not to retain unarrangedChildren and the returned arrangedChildren (first and last line of the arrangedChildren getter). Does the NSSet allObjects method already return a retained array? It's probably too late and I have a coffee overdose. I'd be really thankful if someone could point me in the right direction. I guess I'm missing vital parts of memory management knowledge and I will definitely look into it thoroughly.

    Read the article

  • Get string value of class propery names in Objective-C

    - by Flash84x
    I have the following class definition. Contact.h #import <CoreData/CoreData.h> @interface Contact : NSManagedObject { } @property (nonatomic, retain) NSString * City; @property (nonatomic, retain) NSDate * LastUpdated; @property (nonatomic, retain) NSString * Country; @property (nonatomic, retain) NSString * Email; @property (nonatomic, retain) NSNumber * Id; @property (nonatomic, retain) NSString * ContactNotes; @property (nonatomic, retain) NSString * State; @property (nonatomic, retain) NSString * StreetAddress2; @property (nonatomic, retain) NSDate * DateCreated; @property (nonatomic, retain) NSString * FirstName; @property (nonatomic, retain) NSString * Phone1; @property (nonatomic, retain) NSString * PostalCode; @property (nonatomic, retain) NSString * Website; @property (nonatomic, retain) NSString * StreetAddress1; @property (nonatomic, retain) NSString * LastName; @end Is it possible to obtain an array of NSString objects with all of the properties by name? Array would look like this... [@"City", @"LastUpdated", @"Country", .... ]

    Read the article

  • Modifying existing object attributes in Core Data after the fact

    - by glorifiedHacker
    In a previous question, I was looking for an alternative to modifying how "no date" was being stored in the date attribute of my NSManagedObject subclass. Previously, I had assigned nil to that attribute when a user didn't assign a date. In order to address sorting issues when using NSFetchedResultsController, I have decided to assign [NSDate distantFuture] to the date attribute when a user doesn't assign a date. However, given that this app is already in the wild, I need to update the Core Data store such that any existing nil date values are changed to [NSDate distantFuture]. What is the best way to make this change? The first thing that comes to mind is to iterate through all of the objects in the store in an array and change any nil values that are found. This could be limited to a one-time event by checking against a user defaults key that indicates whether this upgrade has been performed. Is there a way that I can do this with Core Data versioning instead? Or another method that doesn't involve me writing throw-away code?

    Read the article

  • Unable to store NSNumber in core data

    - by Kamlesh
    Hi all, I am using Core Data in my application.I have an attribute named PINCode which has property Int64. Now,in my app I take the PIN code from a text field,convert it into NSNumber and try to store as an attribute value for an entity.But I am unable to do so.The exception that it shows on the console is:- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "PINCode"; desired type = NSNumber; given type = NSCFString; value = 121.' Here is the code:- (Conversion to NSNumber):- NSString *str= txtPINCode.text; NSNumber *num = [[NSNumber alloc]init]; int tempNum = [str intValue]; num = [NSNumber numberWithInt:tempNum]; (Storing in core data entity):- NSManagedObjectContext *context = [appDelegate managedObjectContext]; NSManagedObject *newContact; newContact = [NSEntityDescription insertNewObjectForEntityForName:@"MemberTable" inManagedObjectContext:context]; [newContact setValue:num forKey:@"PINCode"]; The app crashes at this point.I am unable to find the reason of crash.I have also tried to check the conversion by the following code:- NSNumber *testNumber = [[NSNumber alloc]init]; id test = num; BOOL testMe = [test isKindOfClass:(Class)testNumber]; Can anybody help me with this?? Thanks in advance.

    Read the article

  • Core Data confusion: fetch without tableview.

    - by Mr. McPepperNuts
    I have completed and reproduced Core Data tutorials using a tableview to display contents. However, I want to access an Entity through a fetch on a view without a tableview. I used the following fetch code, but the count returned is always 0. The data exists when the database is opened using SQLite tools. NSManagedObject *entryObj; XYZDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Quote" inManagedObjectContext:managedObjectContext]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"id" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [request setEntity: entity]; NSArray *results = [managedObjectContext executeFetchRequest:request error:nil]; if (results == nil) { NSLog(@"No results found"); entryObj = nil; }else { NSLog(@"results %d", [results count]); } [request release]; [sortDescriptors release]; count returned is always 0; it should be 5. Can anyone point me to a reference or tutorial regarding creating a controller not to be used with a tableview.

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >