Search results for

“SwiftData inheritance relationship”

4,980 results found

Post

Replies

Boosts

Views

Activity

Why is Core Data save slow?
I am writing a Mac app using Core Data. I have a model set up with 10 Entities and a number of relationships. Four of the entities will hold 99% of the records. It works great. I wanted to do some performance testing, so wrote code to populate the database with 82,000 managed objects in one of the entities. The others have less with the second highest containing 33,000. The issue I have is that after populating the database and having saved, then when I call the [context save] method every time thereafter, the save takes over 10 seconds, even if I have modified only one attribute in one object. Why is this?The database is about 45MB in total size. It seems like Core Data is saving the whole database instead of just updating the one object.
1
0
1.4k
Jul ’15
NSFetchedResultsController major issue
I was working on a app with Xcode 6/iOS 8 for awhile now. The other day iOS 9 beta 4 and a new Xcode 7 beta was released, and I thought it would be stable enough to update my app to use Swift 2 (100% Swift project). The app supports iOS 8 and 9 now. I ran the app to my iOS 8 device, and noticed a strange effect on NSFetchedResultsController on iOS 8 only (doesn't happen on iOS 9 with Swift 2 for some reason).So here is my implementation of NSFetchedResultsController,func setupReturningShowsFetchedResultsController() { let fetchRequest = NSFetchRequest(entityName: TVShow) let titleSort = NSSortDescriptor(key: title, ascending: true) fetchRequest.sortDescriptors = [titleSort]; let statusPredicate1 = NSPredicate(format: status == 'returning series') let statusPredicate2 = NSPredicate(format: status == 'in production') let statusPredicates = NSCompoundPredicate(orPredicateWithSubpredicates: [statusPredicate1, statusPredicate2]) let predicate = NSPredicate(format: upcomingEpisode == nil) fetchRequest.predicate = N
17
0
11k
Jul ’15
Connecting Outlets and Actions to Super View Controller Stopped Working
Given a class TopViewController that has an @IBAction that prints Wassup Y'all to the screen, when I create another class BottomViewController that inherits from TopViewController, then I can use the Storyboard to connect scene elements from BottomViewController to Outlets and/or Actions in TopViewController.As of yesterday, this has suddenly stopped working and I have no idea what's wrong.I've triedCleaningDeleting DerivedDataRestarting XcodeRestarting MacbookNothing works. Any idea how to get out of this state?
0
0
168
Jul ’15
Reply to How to require a tableview's datasource to conform to my custom protocol
In your subclass, redeclare the delegate property as conforming to your protocol. I assume your protocol is an extension of NSTableViewDelegate. So, you'd declare the property as:- (void)setDelegate:(id <YourProtocol>)delegate; - (id <YourProtocol>)delegate;or, possibly:@property (assign) id<YourProtocol> delegate;In your implementation, you could implement overrides of the accessors which just call through to super. The getter will have to do a type cast since super's declaration is in terms of NSTableViewDelegate.Or, if you used the property declaration, you can simply do:@dynamic delegate;which tells the compiler that the accessors will be available through some means that isn't explicit in this implementation (i.e. inherited).Now, when you invoke self.delegate, it will have the desired type.
Topic: UI Frameworks SubTopic: AppKit Tags:
Jul ’15
Reply to UIView Animations in TableView?
UITableView inherits from UIScrollView which has UITableViewDelegate with scrollViewDidScroll method. So you have to set for example the view controller as a delegate for the table view. ViewController.m:@interface ViewController () <UITableViewDelegate> @property (weak, nonatomic) IBOutlet UITableView *tableView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; / self.tableView.delegate = self; } - (void)scrollViewDidScroll:(nonnull UIScrollView *)scrollView { NSLog(@%f, scrollView.contentOffset.y); // Get the cell from the table view and change the properties } @end
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’15
Segue "show detail" does not work in iOS 7
My first screen is a navigation controller then comes my login view and if I log in and i see my Slide-out Sidebar Menu. I log in with iOS7 but backbutton is superimposed on menu-slide but i can see my menu-slide in iOS 8 and it does not appear the backbutton.When I pass from login to Slide-out Sidebar Menu view, I use segue show detail not inherit the backbutton.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
311
Jul ’15
How to declare a variable with Self or Associated type?
I am working with Swift 2.0 and I have a hierarchy of protocols with this layout.protocol Root { var parent: Self? { get } } func == <T: Main> (left: T, right: T) -> Bool { return left.item.text == right.item.text } protocol Main: Root { var item: Item { get set } } protocol Item: Root { var text: String { get set } }The problem I have is that on line 10 var item: Item { get set } I get the error Protocol 'Item' can only be used as a generic constraint because it has Self or associated type requirements. I can't seem to figure out how to write line 10 to be rid of the error. I tried using a typealias to set a placeholder on line 10 and then line 6 of the infix function return left.item.text == right.item.text throws an error because it doesn't know what type the item variable is. I can't seem to figure out how to define the item variable since it inherits from Root just as Main does. Am I missing something? Any help is greatly appreciated.
0
0
341
Jul ’15
Reply to Protocol-oriented architecture
I'm not sure if I understood correctly. So both ItemCollection and PointCollection should inherit from another protocol that does not have a Self or associated type constraints? So does the same apply to the Match protocol if I want to use it from match controller? It can't have Self or associated type constraints?var match: Match = TennisMatch(participants: [player1, player2) //Error now because Match inherits from ItemCollection
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’15
Reply to Protocol-oriented architecture
Well, to be honest I'm a bit confused. So, I apologize. I've been reviewing your code example, and I think I am missing something. You say, ItemCollection can have both ItemCollections and PointCollections as a child because a match can contain both. By child do you mean an item in the array sets? If so, does PointCollection inherit from ItemCollection because I don't see that in the code? The only addChild() method I see implenented is one that adds a PointCollection but sets doesn't accept PointCollection in the code as it is written.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’15
I need help to understand 2-entity relationship
I can`t fined swift manual with more then 1 entity.For example, i have 2 friends: Jon and David. I created this model core data:1 entity: Frends2 entity: MemoI want save memo for Jon: let entityDescription = NSEntityDescription.entityForName(Memo, inManagedObjectContext: managedObjectContext!) let act = Memo(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext) act.text = Gave me 2 books act.frend.name = Jon var error: NSError? managedObjectContext?.save(&error) if let err = error { println(err.localizedFailureReason) } else { println(Saved) }But I got message nil???
1
0
311
Jul ’15
Why is Core Data save slow?
I am writing a Mac app using Core Data. I have a model set up with 10 Entities and a number of relationships. Four of the entities will hold 99% of the records. It works great. I wanted to do some performance testing, so wrote code to populate the database with 82,000 managed objects in one of the entities. The others have less with the second highest containing 33,000. The issue I have is that after populating the database and having saved, then when I call the [context save] method every time thereafter, the save takes over 10 seconds, even if I have modified only one attribute in one object. Why is this?The database is about 45MB in total size. It seems like Core Data is saving the whole database instead of just updating the one object.
Replies
1
Boosts
0
Views
1.4k
Activity
Jul ’15
NSFetchedResultsController major issue
I was working on a app with Xcode 6/iOS 8 for awhile now. The other day iOS 9 beta 4 and a new Xcode 7 beta was released, and I thought it would be stable enough to update my app to use Swift 2 (100% Swift project). The app supports iOS 8 and 9 now. I ran the app to my iOS 8 device, and noticed a strange effect on NSFetchedResultsController on iOS 8 only (doesn't happen on iOS 9 with Swift 2 for some reason).So here is my implementation of NSFetchedResultsController,func setupReturningShowsFetchedResultsController() { let fetchRequest = NSFetchRequest(entityName: TVShow) let titleSort = NSSortDescriptor(key: title, ascending: true) fetchRequest.sortDescriptors = [titleSort]; let statusPredicate1 = NSPredicate(format: status == 'returning series') let statusPredicate2 = NSPredicate(format: status == 'in production') let statusPredicates = NSCompoundPredicate(orPredicateWithSubpredicates: [statusPredicate1, statusPredicate2]) let predicate = NSPredicate(format: upcomingEpisode == nil) fetchRequest.predicate = N
Replies
17
Boosts
0
Views
11k
Activity
Jul ’15
Connecting Outlets and Actions to Super View Controller Stopped Working
Given a class TopViewController that has an @IBAction that prints Wassup Y'all to the screen, when I create another class BottomViewController that inherits from TopViewController, then I can use the Storyboard to connect scene elements from BottomViewController to Outlets and/or Actions in TopViewController.As of yesterday, this has suddenly stopped working and I have no idea what's wrong.I've triedCleaningDeleting DerivedDataRestarting XcodeRestarting MacbookNothing works. Any idea how to get out of this state?
Replies
0
Boosts
0
Views
168
Activity
Jul ’15
Reply to How to require a tableview's datasource to conform to my custom protocol
In your subclass, redeclare the delegate property as conforming to your protocol. I assume your protocol is an extension of NSTableViewDelegate. So, you'd declare the property as:- (void)setDelegate:(id <YourProtocol>)delegate; - (id <YourProtocol>)delegate;or, possibly:@property (assign) id<YourProtocol> delegate;In your implementation, you could implement overrides of the accessors which just call through to super. The getter will have to do a type cast since super's declaration is in terms of NSTableViewDelegate.Or, if you used the property declaration, you can simply do:@dynamic delegate;which tells the compiler that the accessors will be available through some means that isn't explicit in this implementation (i.e. inherited).Now, when you invoke self.delegate, it will have the desired type.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Jul ’15
Reply to References to a class just ported to Swift appear as forward class objects
The error was due to the capitalization of the class name, totally misunderstood by the compiler, and the need to inherit from NSObject in the Swift class. The general lesson is not bieing creating at all in the porting process as the error messaging is misleading, at best.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’15
Reply to References to a class just ported to Swift appear as forward class objects
No known class method for selector 'alloc'That may happen in some versions of Swift, when @objc put but not inheriting NSObject or its descendent.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’15
Reply to References to a class just ported to Swift appear as forward class objects
Detecting misspelling issue may be very hard, but the latter, not inheriting NSObject, is checked in the latest Xcode 7. Try it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’15
Reply to UIView Animations in TableView?
UITableView inherits from UIScrollView which has UITableViewDelegate with scrollViewDidScroll method. So you have to set for example the view controller as a delegate for the table view. ViewController.m:@interface ViewController () <UITableViewDelegate> @property (weak, nonatomic) IBOutlet UITableView *tableView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; / self.tableView.delegate = self; } - (void)scrollViewDidScroll:(nonnull UIScrollView *)scrollView { NSLog(@%f, scrollView.contentOffset.y); // Get the cell from the table view and change the properties } @end
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’15
Reply to Why does UITableViewController implement initWithCoder, but doesn't conform to NSCoding?
Why do you say that it doesn't conform? It's documented to conform:https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableViewController_Class/Note that the conformance is actually inherited from UIViewController.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’15
Segue "show detail" does not work in iOS 7
My first screen is a navigation controller then comes my login view and if I log in and i see my Slide-out Sidebar Menu. I log in with iOS7 but backbutton is superimposed on menu-slide but i can see my menu-slide in iOS 8 and it does not appear the backbutton.When I pass from login to Slide-out Sidebar Menu view, I use segue show detail not inherit the backbutton.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
311
Activity
Jul ’15
How to declare a variable with Self or Associated type?
I am working with Swift 2.0 and I have a hierarchy of protocols with this layout.protocol Root { var parent: Self? { get } } func == <T: Main> (left: T, right: T) -> Bool { return left.item.text == right.item.text } protocol Main: Root { var item: Item { get set } } protocol Item: Root { var text: String { get set } }The problem I have is that on line 10 var item: Item { get set } I get the error Protocol 'Item' can only be used as a generic constraint because it has Self or associated type requirements. I can't seem to figure out how to write line 10 to be rid of the error. I tried using a typealias to set a placeholder on line 10 and then line 6 of the infix function return left.item.text == right.item.text throws an error because it doesn't know what type the item variable is. I can't seem to figure out how to define the item variable since it inherits from Root just as Main does. Am I missing something? Any help is greatly appreciated.
Replies
0
Boosts
0
Views
341
Activity
Jul ’15
Failed to Inherit CoreMedia permissions from XXXXXX
Every time I launch my photo editing extension, I'm getting the following error:Failed to inherit CoreMedia permissions from 12501: (null)It happens even when I create a totally new app and brand new extension. I'm running Xcode 7 Beta 4.Has anyone else seen this?
Replies
3
Boosts
0
Views
7.1k
Activity
Jul ’15
Reply to Protocol-oriented architecture
I'm not sure if I understood correctly. So both ItemCollection and PointCollection should inherit from another protocol that does not have a Self or associated type constraints? So does the same apply to the Match protocol if I want to use it from match controller? It can't have Self or associated type constraints?var match: Match = TennisMatch(participants: [player1, player2) //Error now because Match inherits from ItemCollection
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’15
Reply to Protocol-oriented architecture
Well, to be honest I'm a bit confused. So, I apologize. I've been reviewing your code example, and I think I am missing something. You say, ItemCollection can have both ItemCollections and PointCollections as a child because a match can contain both. By child do you mean an item in the array sets? If so, does PointCollection inherit from ItemCollection because I don't see that in the code? The only addChild() method I see implenented is one that adds a PointCollection but sets doesn't accept PointCollection in the code as it is written.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’15
I need help to understand 2-entity relationship
I can`t fined swift manual with more then 1 entity.For example, i have 2 friends: Jon and David. I created this model core data:1 entity: Frends2 entity: MemoI want save memo for Jon: let entityDescription = NSEntityDescription.entityForName(Memo, inManagedObjectContext: managedObjectContext!) let act = Memo(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext) act.text = Gave me 2 books act.frend.name = Jon var error: NSError? managedObjectContext?.save(&error) if let err = error { println(err.localizedFailureReason) } else { println(Saved) }But I got message nil???
Replies
1
Boosts
0
Views
311
Activity
Jul ’15