PDA

View Full Version : Adding NSSplitView and Drag/Drop for NSTableView into iProcrastinate!




Littleodie914
Aug 15, 2006, 12:08 PM
Hey ever-so-helpful MR community, I'm back again trying to appease the bajillions of user requests I've gotten for my program, iProcrastinate.

Two that I've been really trying to get to work but can't are splitviews and drag-and-drop support for NSTableView.

SplitView:
Where the heck is it? How exactly do I set up an NSSplitView? I was expecting there to be some nice looking dot on the IB palette you could drag to your app and wah-lah, splitview, but nope. I can't seem to find how to implement this class at all! (I think I just need a nudge in the right direction.)

NSTableView:
Everyone says adding drag/drop functionality to tables is easier than pie, then goes on for pages describing how to get it to work in your app. I've read through countless tutorials both third-party and from Apple, but can't seem to get the hang of things. I've got my tableviews being fed their data from a binding to a Core Data entity, and can't figure out how to assign that as my data type for the acceptable drag/drop action.

Thank you guys so much for all your help in the past, present, and I'm sure future. :) It's people like you guys who make it so easy to make apps like mine free! :D



caveman_uk
Aug 15, 2006, 12:34 PM
Welcome to the world of being a developer and user requests. ;-)

There's an example of drag n drop on mmalcs bindings page (which is damn useful generally) link (http://homepage.mac.com/mmalc/CocoaExamples/controllers.html)

To use splitviews you select the views and make them a subview of an NSSplitView (it's under the layout menu in IB). Splitviews generally suck. In my app I use a split view replacement called RBSplitView which looks nicer but is a bit more work (custom UI code).

caveman_uk
Aug 15, 2006, 12:41 PM
BTW, just looked at your website. I'd watch out about making claims about being bug free. Software rarely is (apart from possibly 'Hello World' and maybe 'Emacs'!). Mine certainly isn't and I doubt yours is (I've got 17,000 lines of code in my program so there's plenty of space for the little buggers to hide)

Be careful what you claim...either directly or indirectly. Maybe I'm just paranoid though...

Littleodie914
Aug 15, 2006, 12:54 PM
BTW, just looked at your website. I'd watch out about making claims about being bug free. Software rarely is (apart from possibly 'Hello World' and maybe 'Emacs'!). Mine certainly isn't and I doubt yours is (I've got 17,000 lines of code in my program so there's plenty of space for the little buggers to hide)

Be careful what you claim...either directly or indirectly. Maybe I'm just paranoid though...Haha true, I actually had forgotten I put that on there. When I originally stated "bug free", I was imagining a beachball-free program, but have since realized a bug can be a dead spot on a table column. :) That said, I'll make the change immediately, thanks for reminding me :D

Ah, and thank you very much for the link, I'll read into it as soon as I get a chance.

Littleodie914
Aug 15, 2006, 02:02 PM
Alrighty. I've been diligently working through both Apple's tutorial and the link you posted, but am still having some difficulty. The "Bookmarks" tutorial you linked to as well as the Apple tutorial both seem to deal with an Array of sorts, while mine deals with Core Data.

At first I figured this wouldn't be a problem, until I tried to compile and realized that none of the methods I use to insert the objects (such as insertObject) will work. It says "DNDController" which is the name of my class that's handling the drag and drop, may not respond to '-insertObject:atArrangedObjectIndex:'.

Yikes! :eek:

Edit: I'm also having trouble determining how I would move objects around, once we get to the

- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
row:(int)row dropOperation:(NSTableViewDropOperation)operation

step since I'm using Core Data to keep track of all of the values.

caveman_uk
Aug 15, 2006, 03:11 PM
As I mentioned I've never used core data so I haven't dealt with it but is this (http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html) any help?

Edit: or this (http://homepage.mac.com/mkino2/backnumber/image/2005_11/DNDCoreData.pdf)

Littleodie914
Aug 16, 2006, 09:51 AM
Gah... I'm having a problem with xcode. :mad:

Every time I create a new project, even if it's a super simple one with only one entity and one attribute, I now get an error:

This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.

Whenever the program opens, tries to save, or closes. The above message is displayed in the console, while the below message comes up as an alert box.

The model configuration used to open the store is incompatible with the one that was used to create the store.

I have no idea what's happening, but I can't fix it. :confused:

Littleodie914
Aug 16, 2006, 10:06 AM
*incoherent babbling*Ah, figured it out. Seems you can't have more than one Core Data app with the same name on the same computer. (Even though they were put in totally different directories?) I guess the data isn't saved inside the application, but rather somewhere else.

I changed the name of the app from iProcrastinate to iProcrastinate2 and all of a sudden the error went away. :)

Littleodie914
Aug 16, 2006, 02:56 PM
Haha back again... I'll keep it short and sweet this time. :)

How would I make a value inserted into a table automatically editable upon being added? Right now you click "Add" and poof, one pops in, but it's just selected. I can't find any way, whether it be through NSTableView, NSArrayController, or bindings to set this newly added value to "editing" mode". Thanks!

P.S. Caveman, thanks so much for the Core Data links, they actually did help a lot! I'm revamping my app to use code for the add/remove buttons rather than the add/remove actions in the NSArrayController, which seems to be making it a lot more flexible! :D

Super Macho Man
Aug 16, 2006, 03:35 PM
Ah, figured it out. Seems you can't have more than one Core Data app with the same name on the same computer. (Even though they were put in totally different directories?) I guess the data isn't saved inside the application, but rather somewhere else.

I changed the name of the app from iProcrastinate to iProcrastinate2 and all of a sudden the error went away. :)
You did know that your data is stored in ~/Library/Application Support/<app name>, right? If you have two apps with the same <app name>, they will try to use the same file by default...

I hope a future release doesn't cause people's assignments to magically disappear... :eek:

Littleodie914
Aug 16, 2006, 06:32 PM
You did know that your data is stored in ~/Library/Application Support/<app name>, right? If you have two apps with the same <app name>, they will try to use the same file by default...

I hope a future release doesn't cause people's assignments to magically disappear... :eek:Haha yes, I've thought about that, and am making sure the program is named the same and loads the same values every time I release a new copy. :D

Any ideas on the automatically-editable problem though? It's really giving me the run around! :(