core-data

Check if property is set in Core Data?

折月煮酒 提交于 2020-01-08 14:37:29
问题 how can i check if an property is set in an Core Data Object? I load all my Core Data Objects in an Directory: var formQuestions = [Questions]() And my Core Data NSManagementObject is: @NSManaged var noticeText: String formQuestions[indexPath.row].noticeText // load with: var fetchRequest = NSFetchRequest(entityName: "Questions") fetchRequest.predicate = NSPredicate(format: "forms = %@", currentForm!) formQuestions = context.executeFetchRequest(fetchRequest, error: nil) as [Questions] My

joins in coredata using Objective C

断了今生、忘了曾经 提交于 2020-01-07 14:38:58
问题 How to make inner joins,outer joins(left,right,full ) in core-data. I have done it easily in sqlite db using sqlite c based APIs But I couldn't find any resources on how to do it using core-data in Objective C. Basically I have a need to query CoreData that involves relation between more than three tables or objects. Note: How to set relationship between tables in core-data would be helpful. such as Primary key - foreign key relationship,cascade relationship . 回答1: To query Core Data you need

Order of sections produced by NSFetchedResultsController?

≯℡__Kan透↙ 提交于 2020-01-07 07:16:24
问题 Does a NSFetchedResultsController assign values for the attribute identified by sectionNameKeyPath to sections always in ascending order? For instance if my sectionNameKeyPath were an (optional) boolean attribute with values @(YES) , @(NO) , @(YES) , would the first section receive one row (because NO corresponds to 0 ) and the second section receive two (because YES corresponds to 1 )? So is that the case and if that is, can one change the order (without introducing another attribute that

How to design Object Graph/Model?

谁说我不能喝 提交于 2020-01-07 06:37:13
问题 JSON As Dictionary { headers = ( { backGroundImageUrl = ""; dataField = Name; headerText = Name; id = Name; itemRenderer = ""; toolTip = ""; width = 60; }, { backGroundImageUrl = ""; dataField = BidPrice; headerText = Bid; id = BidPrice; itemRenderer = ""; toolTip = "Bid Price"; width = 30; }); values = ( { assetCellValueLst = { AskColorCode = "#B8D1ED"; AskPrice = "102.20"; BidColorCode = "#B8D1ED"; BidPrice = "102.00"; Name = "AR Bonar 11"; PECSAsk = 569; PECSChg = "(31)"; PECSChgColorCode

How to design Object Graph/Model?

前提是你 提交于 2020-01-07 06:37:07
问题 JSON As Dictionary { headers = ( { backGroundImageUrl = ""; dataField = Name; headerText = Name; id = Name; itemRenderer = ""; toolTip = ""; width = 60; }, { backGroundImageUrl = ""; dataField = BidPrice; headerText = Bid; id = BidPrice; itemRenderer = ""; toolTip = "Bid Price"; width = 30; }); values = ( { assetCellValueLst = { AskColorCode = "#B8D1ED"; AskPrice = "102.20"; BidColorCode = "#B8D1ED"; BidPrice = "102.00"; Name = "AR Bonar 11"; PECSAsk = 569; PECSChg = "(31)"; PECSChgColorCode

group by date (yyyy/MM/dd) with NSFetchRequest

女生的网名这么多〃 提交于 2020-01-07 05:44:08
问题 i have to count and group on more that 3 properties. i'm pulling my hair while grouping and counting on field with date (yyyy/mm/dd HH:mm:ss) i want to group by year - month - day and ignore the time. but i still need the time for detail view. time zone plays a big role here. so i just save it in utc format. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"logs" inManagedObjectContext:context;

coredata-deleting from database and making request

喜你入骨 提交于 2020-01-07 04:41:31
问题 Hi I am a bit noob whit core-data so I request for your answer, I can pull out data from database whit this functions: NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath]; [[selectedObject valueForKey:@"SOMECOLLUMNNAME"] description]; But I have a really big problems whit deleting from database I have read that I should use NSPredicate I read the tutorial but I do no figure out how can I write a simple DELETE * FROM Table t WHERE t.date == 01.01

fetching core data values using predicate

僤鯓⒐⒋嵵緔 提交于 2020-01-07 04:40:50
问题 my sqlite have items in one of the entity and i wish to retrieve them out according to their categoryID e.g. categoryID 1 have 7 items and categoryID 2 have 5 items , when i clicked on an IBAction it will come to this method and retrieve according to my global.clickedTag but i'm unable to retrieve the values , any idea why? -(NSMutableArray*)fetchItem:array{ [self managedObjectContext]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"IItem" inManagedObjectContext

Alternate way to retrieve data from core data database - ios

会有一股神秘感。 提交于 2020-01-07 03:49:54
问题 I am having performance issues while retrieving data from the database. Right now, this is how I do it. +(NSMutableArray *) searchObjectsInContext: (NSString*) entityName : (NSPredicate *) predicate : (NSString*) sortKey : (BOOL) sortAscending { i3EAppDelegate *appDelegate = (i3EAppDelegate *)[[UIApplication sharedApplication] delegate]; NSManagedObjectContext *context = [appDelegate managedObjectContext]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity =

delete core data managed object with Swift 3

99封情书 提交于 2020-01-07 02:58:27
问题 Swift 3 has migrated my code and changed: context.deleteObject(myManagedObject) to context.delete(myManagedObject) this is compiling fine (XCode 8b3) but at runtime complaining that the context does not have a function/selector delete(managedObject) Here is the runtime error: [NSManagedObjectContext delete:]: unrecognized selector sent to instance My code is very basic: func delete() { let appDel: AppDelegate = UIApplication.shared().delegate as! AppDelegate if let context: