Re: NSComboBoxCell in a NSTableView
On Oct 24, 2009, at 10:04, Timothy Reaves wrote: What is the correct way to size this? I have it added, and it's used. But by default, it doesn't size to hold it's content. I can set he width of the table column to a better width, but I can't seem to find how to size the height. Is there any way to get the table view - or column - to auto-size to correctly hold the combo box cell? -[NSTableView setRowHeight] NSTableView won't autosize, but somewhere in your code you can set the row height to the height of the cell. Also you might consider setting a different control size on the cell. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core data design related question
Hi Marc, On Oct 20, 2009, at 16:11, Marc Rink wrote: Heyas, I am quite new to Objective-C (and to some extend to OO concepts as well), so please be gentle with me :) I have a core data based document application that purpose is to access a mysql database (i am using the MCP Kit). The documents in my context are Views that contain different aspects of the database (small portions consisting of some tables related to each other). One document contains the connection parameters for the database. I am switching the views according to Aaron Hillegass' example using a view controller (the downloadable examples are http://www.bignerdranch.com/solutions/Cocoa-3rd.tgz) . I want to achive the following: Upon application start the first view ConfigViewController is shown. It contains all connection related parameters (such as host, port, user, password and database) and a Connect button. Upon clicking the Connect button, the connection to the database is established. The result is a connection object, that i wanted to pass around the different Views. First approach was to pass the resulting connection to the superclass of the view's (all my view's are derived from a custom superclass which extends NSViewController). For reasons i dont know, i didnt get this to work. The resulting object was invalid (nil) in the other view's. Second approch (and better one imho) is to add a core data entity DBConfiguration holding all connection parameters (persistent, so you dont have to enter the stuff every time) and a transient property for the connection object (of type undefined). I added a Object Controller to my documents xib file, set the mode to Entity and the entity name to DBConfiguration. My Problem now is: The view containing the textfields and the connect button are in a different xib file (ConfigView.xib, whose Files Owner is of Type ConfigViewController. I dont know how to bind the ConfigView's text fields to the Object Controller in MyDocument.xib. OK, this was a lot of info. What is your actual problem? Can't you simply make another object controller for DBConfig in ConfigView.xib? Also note that CoreData is probably not the right solution for storing your connection info. From what you say the user defaults system seems much more appropriate. I am still new to the different frameworks and unsure about whether my design is acceptable or if i am on a completely wrong way. When taking on so much at once (as you claim to be inexperienced), it is almost guaranteed you are not doing things the right way. Still, your app seems quite complex and it does not make sense trying to explain it all when looking for a solution for a reasonably small problem. I am sure you'd get more answers if you put the question to the point. Also, if you are really new to all of this stuff, this sounds like a big first step. Too big. Start with small, isolated functionalities and practice. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core data design related question
On Oct 22, 2009, at 15:46, Marc Rink wrote: This means i need the ObjectController in every view i want to have access to the connection parameters. Yep, that seems right. However, i am now troubling around: I set the value Binding of the Textfield to the object Controllers.selection.value in IB, however i wont see the defaultvalue i have set in the model designer in Xcode. I already fiddled around with Enabled and editable bindings, but i didnt get it to work...? Anyone able to point me in the right direction? I am not sure exactly what should be happening as I never used an NSObjectController with CoreData fetching (normally use array and tree controllers). What gets fetched? One record? All records? No idea... However, this should all be fairly simple to track down... 1. Make sure your default value is actually getting set on new objects. 2. Check what the fetched content of the object controller is at the point in which you expect your connection info in it. 3. Check what the object controller's selection is at the same time. ... This is one of those situations which should just work, unless you omit one of the myriad small steps necessary to get there. As such it's hard for anyone but you to find it. So check your assumptions one by one and experiment... F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding Enabled property to NSArrayController selection
Hi Matthew, On Oct 19, 2009, at 07:08, Matthew Lindfield Seager wrote: As discussed previously on this list I am using the data source methods of NSOutlineView to display the contents of two separate NSArrayControllers. When an item is selected I use outlineViewSelectionDidChange: to manually update the selection of the appropriate array controller and deselect all items in the other array controller (i.e. I pass an empty index set to setSelectionIndexes). I would like a toolbar item to only be enabled when an item in the first controller is selected so I tried binding it's Enabled property to selectedobjec...@count and then canRemove. With either binding when the selection changes I see the button flicker as though it is being disabled and then reenabled but it never stays disabled. I verified that empty selections are allowed. I am observing changes to the outline view's selectionIndex and I can verify that even though [[myArrayController selectedObjects] count] == 0, the item is not [staying?] disabled. Using the No Selection Placeholder value doesn't make a difference either. Out of curiosity/desparation I even tried the inverse (enabling it when an object from the other array controller is selected) and two different complements (disabling it when an object from the other array controller is selected AND disabling it when an abject from this controller is not selected). No matter what I tried it would only flicker when I was expecting it to stop being enabled. Am I missing something obvious? I think so... When binding the enabled state of a toolbar item you need to make sure that the item does not autovalidate. The Autovalidates checkbox can be found in the attributes panel of the inspector for a toolbar item. I am not sure if this is a bug or not, and it is NOT mentioned in the bindings reference for NSToolbarButton, so it's a bit tricky to figure out. Since usually bindings override the non-bound state I can see this as a bug, but my experience with Cocoa is not wide enough to judge... Anyone else? Regards, Matt P.S. The following two threads rhetorical(from quite some time ago - is Leopard REALLY that old?)/rhetorical seem to discuss something similar but neither post was answered. http://www.cocoabuilder.com/archive/message/cocoa/2007/1/6/176732 http://www.cocoabuilder.com/archive/message/cocoa/2007/12/28/195544 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding Enabled property to NSArrayController selection
On Oct 19, 2009, at 07:59, Matthew Lindfield Seager wrote: 2009/10/19 Stamenkovic Florijan flor...@mac.com I think so... When binding the enabled state of a toolbar item you need to make sure that the item does not autovalidate. The Autovalidates checkbox can be found in the attributes panel of the inspector for a toolbar item. I am not sure if this is a bug or not, and it is NOT mentioned in the bindings reference for NSToolbarButton, so it's a bit tricky to figure out. Since usually bindings override the non-bound state I can see this as a bug, but my experience with Cocoa is not wide enough to judge... Anyone else? One little check box!!! Argh! Thank you very much for your help! Sure... At the very least I should probably log a documentation request for the binding's reference (there's not much to the NSToolbarItem Bindings section but I read it several times to make sure I wasn't missing anything!). Right... I was just thinking about this a bit. Unlike with most bindings, I guess it is possible to use both the standard autovalidation and the binding at the same time. As it seems that autovalidation is postponed until the next cycle of the run loop. So, if using autovalidation one could consider the current state of the item and add to that some custom validation logic. However, this is pure speculation. I possibly should have cottoned on to the fact that every search I performed talked more about validation than bindings. If I didn't receive an answer I was going to delve into validation but I really don't have the time at this moment in time so I'm VERY grateful for your help! Well, the toolbar programming documentation does not discuss this in it's validation part either. In fact, it does not even mention the autovalidate property of NSToolbarItem. So, even if this behavior is intended, it seems to be 100% undocumented. I will confirm this on Snow Leopard, as I didn't get around to it yet, and report it as a bug as well. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Toolbar with capsule style items (Similiar to Mail)
On Oct 15, 2009, at 13:39, Mazen Abdel-Rahman wrote: Hi All, I am new at programming with Cocoa - so I had a basic question. Is it possible to create a capsule style toolbar with a search field in it (like how Mail's toolbar is) just using interface building to create the UI? And if so - how would it be done? I am trying to create by first dragging a Toolbar item to the window. When I try to put a segmented control or a search control in the toolbar it gets rejected. If I understand you correctly you are dragging things into the toolbar itself, on the window. What you need to do is first double click the toolbar. This will bring up a sheet similar to what you get when customizing the toolbar in whichever app. You drag toolbar elements into that sheet from the IB palettes. Then, to customize the toolbar itself, you drag items from the sheet into the toolbar area of your window. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: grouping undo across method calls in CoreData
Jim, An interesting situation. I do not have anything definitive, but just some ideas and comments On Oct 05, 2009, at 09:10, Jim Thomason wrote: -(void) createOrder { int highOrderIndex = [self getHighestIndexSomeHow]; [self setValue:[NSNumber numberWithInt:highOrderIndex] forKey:@ordered]; } Hm, do operations using primitive accessors also get registered on the undo stack? If not, you could maybe use that approach, so the setting of the ordered value would not ever get registered? Or maybe you could disable / enabled undo registration in createOrder like: NSUndoManager* um = ... [um disableUndoCreation]; int highOrderIndex = [self getHighestIndexSomeHow]; [self setValue:[NSNumber numberWithInt:highOrderIndex] forKey:@ordered]; [um enableUndoRegistration]; Have you tried something like this? From what I understand you don't need to have the change of the ordered value on the undo stack, and either of these could make that happen... ... How can I deal with this? I've been trying various combinations of begin/endUndoGrouping, and even turning on and off groupsByEvent, but I haven't hit the magic incantation yet. I guess it is tricky dealing with begin/endUndoGrouping when using delayed invoking. Still, AFAIK it should work. Can you elaborate on why it does not? I also tried popping all references to the newly created object off the stack and using prepareWithInvocationTarget: with a method that just drops the object: ... //at the end of createOrder up above [undoManager removeAllActionsWithTarget:self]; [[undoManager prepareInvocationWithTarget:self] negateCreation]; } -(void) negateCreation { [[self managedObjectContext] deleteObject:self]; } That gets me closer - it actually does drop the object immediately upon undo, but I still have an additional undo state on the stack. Which extra undo state do you have? What is the registered undo that does nothing? That is, I can hit undo once and delete my object entirely, but then I can hit undo a second time, and seemingly nothing happens. At that point, I can hit redo twice, and two additional objects will appear. One with a valid order, and one without. I'm not sure if this approach is a dead-end or not. No idea... The concept makes sense though. HTH, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView: no display until header clicked
On Oct 05, 2009, at 13:08, Volker in Lists wrote: so you seemed to have populated the array controller in a non KVO way... but still, w/o code not to be discussed. I think that is the problem. If you bind the content of an NSArrayController to someObject.variable, then the controller will be notified of a change in it's content only if you assign a different object (NSArray) to the variable, but NOT if you manipulate the contents of the array. Instead, you need to manipulate the contents of the variable via the controller. So, instead of populating the mutable array directly in your windowControllerDidLoadNib method, try populating it via the controller. HTH, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Solved] Re: NSTableView: no display until header clicked
On Oct 05, 2009, at 14:05, Kyle Sluder wrote: On Mon, Oct 5, 2009 at 10:39 AM, David Hirsch dhir...@mac.com wrote: NSArrayController has things like insert: or add: Okay... not sure what that has to do with anything. NSArrayController's content is usually bound to an ordered property (itself often an NSArray) and is usually used to provide data for UI elements. That is one of it's uses. It is also commonly used to add, insert and delete objects in it's content. In a KVO friendly way. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSOutlineView - Automatically select newly added item - Help needed
On Oct 05, 2009, at 19:44, Mario KuĆĄnjer wrote: Hello to the list ! Request for help regarding a little problem. So I have this piece of code: - (IBAction)addNewItem:(id)sender { if ([lsOutlineView selectedRow] 0) { [sourceListLevelZero addObject:[Parent new]]; [lsOutlineView reloadItem:nil reloadChildren:YES]; [lsOutlineView expandItem:nil expandChildren:YES]; Can't comment on this part as I am not exactly sure what you are doing. However note that in the first line of the block above you are most probably retaining an object twice. This is not a leak if you insist on garbage collection, but otherwise it is. [lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: [lsOutlineView rowForItem:[Parent new]]] byExtendingSelection:NO]; Well, assuming that you wanted to select the Parent item you added to the sourceListLevelZero, you should query the outline for the row index of *that* item, and not of a new Parent. Besides that to me the line makes sense... HTH, F } ... } It is the last line that trouble's me. It should select newly added item in the list (right ?), but it does not ! Or am I doing something wrong (very likely !) ? Ok, so you got it by now that I am trying to get the behavior that when user clicks add button new item that appears in the list automatically gets selected. Thanks for help Bye ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core-data binding to all entities
Martin, I am actually working on an identical app (as far as your description goes), as a way of learning CoreData, but also to have something to organize my todos and reminders in... I am dealing with the same problem you describe below, though I took a slightly different approach. I bind the contentSet to the selected Group's notes relationship, but when I unbind it I do not manually fetch all the notes like you do. Instead, my notesController is set to fetch them itself, so I just need to invoke the fetch method. However, for some reason the canRemove property of the notes controller turns to NO after I unbind the contentSet, so I also can not delete notes... What is weird is that this only happens after I have had the notesController bound over the groupsController during a run of the app. It seems that switching the content like this is not well supported, and tends to confuse the controller. In that sense I will change my code to perform filtering of notes based on the selection in the outline of groups, as opposed to using this approach. There is another problem with this approach... For more info see a recent post of mine on the cocoa dev list titled: Dynamic NSArrayContent changing [was: NSTableColumn value binding] If you like, we can exchange our apps offlist, it might be interesting to compare features etc. Best regards, F -(void)setViewingAllNotes:(NSNumber*)newValue { // assign the new values id oldValue = viewingAllNotes; viewingAllNotes = [newValue copy]; [oldValue release]; // react appropriately if([viewingAllNotes boolValue]){ // cache and then remove the current selection of the groups controller lastSelectedGroupsIndexPaths = [[groupsController selectionIndexPaths] retain]; [groupsController setSelectionIndexPaths:nil]; // re-direct the bindings of the notesController [notesController unbind:@contentSet]; [notesController fetch:self]; }else{ // re-direct the bindings of the notesController [notesController bind:@contentSet toObject:groupsController withKeyPath:@selection.items options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSDeletesObjectsOnRemoveBindingsOption]]; // restore and then release the last selection of the groups controller [groupsController setSelectionIndexPaths:lastSelectedGroupsIndexPaths]; [lastSelectedGroupsIndexPaths release]; lastSelectedGroupsIndexPaths = nil; } } On Oct 02, 2009, at 02:39, Martin Hewitson wrote: Dear list, I have a simple core-data model with an entity 'Category' and an entity 'Note'. The 'Category' entity has a to-many relationship 'notes' to entity type 'Note'. The categories are displayed in an outline view via a tree controller. There is also a table which displays the contents of an array controller (NotesArrayController) - this is supposed to show a subset of the notes. I have a switch on the UI which is meant to let the user choose whether to display all notes in the currently selected category, or all notes from all categories. So I want to modify the content of NotesArrayController depending on the state of the switch. So far I tried doing this programatically with bindings using the two methods below (actually the switching mechanism is just two buttons). This works as far as displaying the correct content to the user, but when it comes to deleting objects when in 'all categories' mode, it doesn't work properly. I get messages in the console like: *** -[NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object So that's pretty clear, and I'm obviously going about this in the wrong way. The question is, what is a proper way to handle this? Thanks in advance for any constructive comments, Martin #pragma mark - #pragma mark Category control - (IBAction)allCategoriesSelected:(id)sender { [singleCategoryButton setState:0]; [allCategoriesButton setState:1]; [notesArrayController unbind:@contentSet]; [notesArrayController unbind:@contentArrayForMultipleSelection]; [notesArrayController setContent:nil]; NSManagedObjectContext *moc = managedObjectContext; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@Note inManagedObjectContext:moc]]; NSError *error = nil; NSArray *results = [moc executeFetchRequest:request error:error]; if
Subclassing NSPredicate
Hi all, The documentation does not discuss this as all, as far as I have looked through it. Googling brings up nothing. So I am wondering: is anyone doing this? Any caveats? I can live without it, but it would make what I am doing easier if I could subclass it. TIA, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Subclassing NSPredicate
On Oct 02, 2009, at 12:17, Nick Zitzmann wrote: On Oct 2, 2009, at 10:08 AM, Stamenkovic Florijan wrote: The documentation does not discuss this as all, as far as I have looked through it. Googling brings up nothing. So I am wondering: is anyone doing this? Any caveats? With a few exceptions (NSObject, NSFormatter, NSProxy, NSOperation, etc.), objects in Foundation are not made to be subclassed, unless you really know what you're doing. This makes sense. I've noticed that a number of classes discuss subclassing in their documentation, and others (like NSPredicate) ominously avoid the subject. What exactly are you trying to accomplish? If you're just trying to add methods to the class, then make a category instead. At the moment nothing that I can't do with a compound predicate. It was more of a conceptual question, as writing custom filtering logic allows more flexibility, and is a handy thing to be able to do. I guess I will just do it the standard way, for the time being, Thx, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deleting CalTasks through an Array.
Hi Joshua, You're welcome, but you need to also learn some stuff on your own. 1. Browse the docs: NSArray does not have a contains: method, it has a containsObject: method. My mistake, but one that's easy to spot. 2. Check the method signatures for CalCalendar store. I believe I gave you the right ones (in which case your imports are somehow messed up). If I gave you the wrong ones, change them. Also please keep all communication *on* the list. F On Oct 01, 2009, at 01:54, Joshua Garnham wrote: Thanks! I've got a few warnings though : http://snapplr.com/zm6w. Especially with the NSPredicate. From: Stamenkovic Florijan flor...@mac.com To: Joshua Garnham joshua.garn...@yahoo.co.uk Cc: cocoa-dev@lists.apple.com Sent: Wednesday, 30 September, 2009 20:24:59 Subject: Re: Deleting CalTasks through an Array. On Sep 30, 2009, at 12:32, Joshua Garnham wrote: I have an Array of strings and want to remove CalTasks with titles of any of the strings. I know I can loop through a array with for(NSString *title in array) { } and delete tasks with removeTask:title error:nil But it won't let me delete a CalTask object with the strings from the Array instead it wants the actual CalTask object.How would I delete a CalTask object by matching it's title to a string in an array? Joshua, You need to use CalCalendarStore's method taskPredicateWithCalendar, passing it all calendars to get the tasks, then compare titles and delete if necessary. // make a predicate for all tasks NSPredicate* allCalendarsTaskPredicate = [CalCalendarStore taskPredicateWithCalendar:[CalCalendarStore calendars]]; // fetch all the tasks NSArray* allTasks = [[CalCalendarStore defaultCalendarStore] tasksWithPredicate:allCalendarsTaskPredicate]; // delete them for(CalTask* task in allTasks) if([arrayOfTitles contains:tast.title]) // delete task More or less... Sorry for the typos, I am writing directly to mail. What would be more efficient and *might* work is creating a compound predicate out of the allTasks predicate and a predicate that would discriminate tasks that don't have a matching title. However, I am not sure that predicate would work with the CalendarStore. Something to explore if the performance is an issue. HTH F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Mixed Core Data and static nodes in outline view
On Sep 30, 2009, at 20:58, Rick Mann wrote: On Sep 30, 2009, at 16:22:45, Rick Mann wrote: I'm looking at ways of grouping some Core Data objects in a outline view. What I have are 3 or 4 different entities, and I want each of the objects of each type to appear under a parent item in the outline view. Currently, I've implemented a simple table view and it's bound to an array controller that gets the objects from Core Data. Now I want to expand that same list to handle the other objects, so an outline view seems natural, with the top level nodes corresponding to the various types of entities, and the entities existing below. Since the model doesn't have any notion of groups, I'd like to programmatically create the top entities, and have core data manage the children of each. Is this even possible? Do you think I could create an plain Obj-C object with appropriate accessors to act as my grouping object, and then have it implement Core Data fetch operations to return the children? I don't know, though, how to get changes in the managed object context to be automatically reflected in the tree view using this technique. I'm sure there's some observer/key notification thing to set up, but I'm not very fluent in the programmatic aspects of that stuff. I was thinking about something similar. I guess you would need to encapsulate an arbitrary number of NSTreeController objects in a custom object that behaves like an NSTreeController. I have decided against it thought because I am quite convinced it would be a *lot* more difficult to do properly (even if it is possible) then to implement a custom NSOutlineViewDataSource. Still, you might be able to use NSTreeControllers as a starting point in your data source, which should make it easier to observe records being created / deleted / modified. Hm, it might be a better idea to use NSArrayControllers for each of your entities and observe those instead. Another option is to simulate this in the GUI using a number of NSOutlineViews each wired separately. You would need to synchronize selections between them though. And you would need to deal with sizes / positioning manually. This might be a *bit* easier, but like with every hack: expect problems. I think that your best option is to sit down, dig through the relevant technologies, and do it. I don't think there's an easy way to accomplish this. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableColumn value binding + keypath over a relationship
On Sep 30, 2009, at 10:22, Bryan Matteson wrote: I'm going to take a stab in the dark and predict that you *don't* have rearranges content automatically checked for the array controller, I do. and that checking it will cause the error message to go away. It does not. Try unchecking it. I tried it, did not help. Besides, I need automatic resorting (automatic at least from the user's point of view), and this is the cleanest way of doing it. http://stackoverflow.com/questions/1028700/core-data-strange-bindings-error-on-re-opening-a-document-help Similar behavior (not the same), and I am not getting any formatter related Console messages that are mentioned on that thread. I could be messing things up some other way though. Will try to isolate the issue. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Dynamic NSArrayContent changing [was: NSTableColumn value binding]
On Sep 30, 2009, at 10:36, Bryan Matteson wrote: May also want to look at this. http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg31802.html It seems to be very possible that it may be a bug, but it's also a common coding mistake as well. Hope it works itself out. Bryan, I looked into it. The problem described relates to willChangeValueForKey not being called, thus violating KVO. This is not the problem I have. Further investigation seems to suggest that it is an action of mine that triggers this. And not even the workaround that I have been using fixes it. Actually, completely removing the table column in question does not fix it. The problem is elsewhere, but I have a lead... I dynamically change the content set / array of my array controller as a user preference changes. The situation is that there is a user preference for see all notes. If it's value is YES, then I bind my array controller's array content to another array controller that simply fetches all Notes. if it is NO, then I bind my array controller's set to NSTreeController.selection.items (where selection is a Group, and items the Notes it relates to)... It seems that this change is causing this to happen... Here is some extra weirdness... The error is exhibited only when I shift back to not viewing all notes. So, when I first start up the app, I can drag and drop no problem, regardless if viewing all notes or the notes from the selected group. If I shift from seeing group notes to seeing all, also no problem. Only when shifting from seeing all to seeing selected group notes do I get this problem. Perhaps I am not allowed to this, or need to do it differently? Here is the code for the change... I will experiment with it... It is a setter for a property bound to NSUserDefaultsController.values.viewingAllNotesPref -(void)setViewingAllNotes:(NSNumber*)newValue { // assign the new value id oldValue = viewingAllNotes; viewingAllNotes = [newValue copy]; [oldValue release]; // react appropriately if([viewingAllNotes boolValue]){ // cache and then remove the current selection of the groups controller lastSelectedGroupsIndexPaths = [[groupsController selectionIndexPaths] retain]; [groupsController setSelectionIndexPaths:nil]; // re-direct the bindings of the notesController [notesController unbind:@contentSet]; [notesController bind:@contentArray toObject:allNotesController withKeyPath:@arrangedObjects options:nil]; }else{ // restore and then release the last selection of the groups controller [groupsController setSelectionIndexPaths:lastSelectedGroupsIndexPaths]; [lastSelectedGroupsIndexPaths release]; lastSelectedGroupsIndexPaths = nil; // re-direct the bindings of the notesController [notesController unbind:@contentArray]; [notesController bind:@contentSet toObject:groupsController withKeyPath:@selection.items options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSDeletesObjectsOnRemoveBindingsOption]]; } } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Deleting CalTasks through an Array.
On Sep 30, 2009, at 12:32, Joshua Garnham wrote: I have an Array of strings and want to remove CalTasks with titles of any of the strings. I know I can loop through a array with for(NSString *title in array) { } and delete tasks with removeTask:title error:nil But it won't let me delete a CalTask object with the strings from the Array instead it wants the actual CalTask object.How would I delete a CalTask object by matching it's title to a string in an array? Joshua, You need to use CalCalendarStore's method taskPredicateWithCalendar, passing it all calendars to get the tasks, then compare titles and delete if necessary. // make a predicate for all tasks NSPredicate* allCalendarsTaskPredicate = [CalCalendarStore taskPredicateWithCalendar:[CalCalendarStore calendars]]; // fetch all the tasks NSArray* allTasks = [[CalCalendarStore defaultCalendarStore] tasksWithPredicate:allCalendarsTaskPredicate]; // delete them for(CalTask* task in allTasks) if([arrayOfTitles contains:tast.title]) // delete task More or less... Sorry for the typos, I am writing directly to mail. What would be more efficient and *might* work is creating a compound predicate out of the allTasks predicate and a predicate that would discriminate tasks that don't have a matching title. However, I am not sure that predicate would work with the CalendarStore. Something to explore if the performance is an issue. HTH F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTableColumn value binding + keypath over a relationship
Hi all, I have been experiencing an error in my app that does not make sense... Here is the situation: A CoreData app. I have a table and one of it's columns' value bound to an array controller's arrangedObjects.group.title. The controller contains objects of the Note entity. Note relates to a Group (to-one), and the Group entity has a title attribute. Straightforward. Next to the table I have an outline view containing Groups. I have implemented drag and drop so that Notes can be dragged from their table to a different group in the outline view. However, when I have the above described table column present in the table, I get an error after dragging that says: Cannot remove an observer NSTableBinder 0x177eb0 for the key path group.name from FSNote 0x1ad240, most likely because the value for the key group has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the FSNote class. I am quite certain that the Note class is KVO compliant for group, since I don't do anything to prevent it being, and it's a CoreData entity with @dynamic property generation. So, I am wondering, am I doing something wrong? It seems a reasonable thing to do, binding a column's value to the arrangedObjects.relationship.attribute key path, but maybe that is not allowed? I have managed to work around this by binding the column to arrangedObjects.group, and using a custom value transformer. This provides me with exactly the functionality I need, but I am still wondering about the mechanics, and if I am doing something wrong. Thanks in advance, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableColumn value binding + keypath over a relationship
On Sep 29, 2009, at 17:37, Bryan Matteson wrote: Cannot remove an observer NSTableBinder 0x177eb0 for the key path group.name from FSNote 0x1ad240, most likely because the value for the key group has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the FSNote class. Means exactly what it says. Somewhere you changed the value of a group object without using KVC. So, I am wondering, am I doing something wrong? It seems a reasonable thing to do, binding a column's value to the arrangedObjects.relationship.attribute key path, but maybe that is not allowed? It IS allowed, and the best way to go about it. I have managed to work around this by binding the column to arrangedObjects.group, and using a custom value transformer. This provides me with exactly the functionality I need, but I am still wondering about the mechanics, and if I am doing something wrong. This is probably not correct. Check your outlineView's delegate methods where you have implemented drag and drop. Somewhere along the way you are changing a value without using the mutators. If you can't find it, post the relevant code (i.e. the all drag-and-drop related code from the outline view) and I'll help you spot it. Bryan, Quincey, Thanks for your replies. As for the group.name vs. group.title that Quincy mentions, it's a typo in the email, not in the project. As for messing up / not using KVO properly, I suppose that somehow I am not, but I don't see how. I have read most of the CoreData docs and have experience with similar technologies (WebObjects), and am fairly certain I am not doing anything obviously wrong... Also what is interesting is that I can As for what Bryan mentions, that I am changing an attribute in a non- KVO-compliant way, I do not think so. In that sense the message I am getting is a bit misleading (also note that it says ...most likely because...)... Bryan, you say that my workaround is probably not correct. Why? I understand it is a long and not the-right-way, but the-right-way does not seem to work for me at the moment. As for the code in the outline view data source, here it is, I am not changing the value without using the mutators, but perhaps it is relevant: - (BOOL)outlineView:(NSOutlineView*)outlineView acceptDrop:(id NSDraggingInfo)info item:(id)proposedParentItem childIndex:(NSInteger)proposedChildIndex { NSPasteboard* pboard = [info draggingPasteboard]; NSArray* pboardTypes = [pboard types]; // Notes being dragged if([pboardTypes containsObject:FSNoteIDURIsArrayPBType]){ // the group dragged to NSManagedObject* group = [((NSTreeNode*)proposedParentItem) representedObject]; // the URIs of Notes being dragged NSArray* noteURIs = [NSKeyedUnarchiver unarchiveObjectWithData:[pboard dataForType:FSNoteIDURIsArrayPBType]]; NSUndoManager* um = [[group managedObjectContext] undoManager]; // relate the notes to the group dragged into // do it as a single undoable op [um beginUndoGrouping]; for(NSURL* noteURI in noteURIs){ // app delegate is the where the managed object URI - managed object reference logic resides FSNote* note = (FSNote*)[appDelegate objectForURI:noteURI]; note.group = group; } [um endUndoGrouping]; return YES; } // accepting also other drag types (reordering of Groups contained in the outline view), code that does that is here ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableColumn value binding + keypath over a relationship
On Sep 29, 2009, at 19:21, Quincey Morris wrote: On Sep 29, 2009, at 15:27, Stamenkovic Florijan wrote: // the group dragged to NSManagedObject* group = [((NSTreeNode*)proposedParentItem) representedObject]; // the URIs of Notes being dragged NSArray* noteURIs = [NSKeyedUnarchiver unarchiveObjectWithData:[pboard dataForType:FSNoteIDURIsArrayPBType]]; NSUndoManager* um = [[group managedObjectContext] undoManager]; // relate the notes to the group dragged into // do it as a single undoable op [um beginUndoGrouping]; for(NSURL* noteURI in noteURIs){ // app delegate is the where the managed object URI - managed object reference logic resides FSNote* note = (FSNote*)[appDelegate objectForURI:noteURI]; note.group = group; } [um endUndoGrouping]; I dunno, this is where my head starts to hurt. According to your error message, there was an observer of a Note (well, FSNote) object for key path group.name. I figured that out. And I am fairly sure it is a binding mediator between the column and the array controller, because if I remove that column, I don't get the error. However, your binding is via arrangedObjects. Now, although the array controller may be KVO compliant for the property arrangedObjects, the arrangedObjects array isn't itself KVO compliant for anything, because arrays just aren't. So although 'note.group = group;' is generating the correct notification, maybe it just isn't flowing through the array controller to the binding mechanism. Hm... I am thinking something similar. However, it seems to me that every item in the contents of an array controller is observed for relevant paths. Which can be witnessed when binding a table column's value to an attribute of an item in the controller. For example, arrangedObjects.firstName in a Person. So, it seems that an array controller provides KVO compliance for it's contents (arrangedObjects) as well as for the properties of items in that array. My situation seems to imply this too. If I bind to arrangedObjects.group, and use a value transformer, I get both the correct behavior and updates in the NSTableView resulting when I change a Note's group relationship. Where it seems to fail is when stretching that path. Somehow the array controller seems to be able to handle itemNoX.relationship, but not itemNoX.relationship.attribute. I'm going to take a stab in the dark and predict that you *don't* have rearranges content automatically checked for the array controller, I do. and that checking it will cause the error message to go away. It does not. (Or, equivalently, you could send a rearrangeObjects message to the array controller immediately after 'note.group = group;'.) I am not sure where you are going with this, but I have tried it, and it does not change the behavior. F if nobody comes up with a you are doing this wrong, do it like this by tomorrow I will try to isolate this in a small case. Maybe I am causing this somewhere else in my code. I think not, but best to check. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie question - core data
Darren, On Sep 14, 2009, at 09:11, Darren Wheatley wrote: Hi, I'm learning Cocoa / Objective-C. Right now I'm trying to build a simple Core Data application. I've built a helper app to read in CSV and populate an XML core data store. That works fine. I have seen lots of examples of binding a view to core data entities so that the contents of the store are loaded into the view when the application runs. I'm comfortable with how this works. However, I want my application to start with an empty view, then have the user enter a search string, and only then display the data that matches the search string. I know I can use NSPredicate to filter the data but don't know how to hook it up in this way. I've read through the Core Data Programming guide, had a look through Marcus Zarra's book, but I just can't get my head around how this should work. Is this something that I can / should do with Core Data? How do I filter the data before displaying anything in the view? If anyone could point me at some sample code / articles etc. that might help fill in the blanks I would appreciate it. I am also a beginner at CoreData / Cocoa, so what I say below is not guaranteed to work, and has not been tested... Assuming you have an NSArrayController that you use in your interface... You should set automaticallyPreparesContent to NO, in Interface Builder or programatically. Then, after you set the fetch predicate on the controller, you should invoke either fetch: or prepareContent: manually on the controller. Not sure about what the difference between the two would be, look into the docs for info on this. Alternatively, you can use your controller as a non-CoreData controller, and set it's content manually, after you perform a fetch manually. HTH, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView resizeability and scrolling
On Sep 11, 2009, at 13:36, Ross Carter wrote: It looks like you instantiate the NSTextView in the nib. I would start by setting up the NSTextView manually and adding it as a subview to your FSEmbeddedTextView2 instance. Make sure that the textView has its resizing behavior set up correctly (vertical, horizontal, both, depending on your needs). Next, I would make sure that you are getting the frame changed notification and that it is firing embeddedTextViewFrameDidChange:. Hi Ross, This all worked and was double checked before I made my original post... I have investigated this further, and came up with an implementation that works flawlessly, as far as I have tested it. It produces the desired resizing when editing text, as well as when resizing the ancestor scroll view (typically as a consequence of window resizing). It is based on the manipulation of the textViews self-resizing flags at appropriate times. Here is the implementation, in case anyone is interested: Oh, there is no documentation so let me point something out. This implementation works under the assumption that the FSEmbeddedText (the name sucks, I have yet to figure out an appropriate name for this class) is contained in an NSScrollView, directly. For it to work, the textView outlet needs to be connected to an NSTextView that is a descendant view of the FSEmbeddedTextView. I believe it does not have to be a direct subview, but I have not tested this assumption yet... @interface FSEmbeddedTextView : NSView { IBOutlet NSTextView* textView; NSRect textViewFrame; BOOL isAutosizing; NSScrollView* scrollViewAncestor; } @end @implementation FSEmbeddedTextView -(void)awakeFromNib { // find the scroll view ancestor and keep a reference for(NSView* superview = [self superview] ; superview != nil ; superview = [superview superview]) if([superview isKindOfClass:[NSScrollView class]]){ scrollViewAncestor = (NSScrollView*)superview; break; } if(textView != nil){ // track the frame of the text view textViewFrame = [textView frame]; isAutosizing = NO; // observe notifications of the text view resizing [textView setPostsFrameChangedNotifications:YES]; NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(embeddedTextViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:textView]; } } -(void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { // first turn off autoresizing on the text view // this will make the NSTextView resize itself in the standard NSView fashion [textView setHorizontallyResizable:NO]; [textView setVerticallyResizable:NO]; // then do the resize isAutosizing = YES; [super resizeSubviewsWithOldSize:oldBoundsSize]; isAutosizing = NO; // now turn the resizing back on [textView setHorizontallyResizable:NO]; [textView setVerticallyResizable:YES]; // and make the text view resize to fit [textView sizeToFit]; } -(void)embeddedTextViewFrameDidChange:(NSNotification*)n { // only react to this if this view is not currently autosizing if(!isAutosizing){ // find out the diff between the old text view size // and the new size NSRect newTextFrame = [textView frame]; float increaseX = newTextFrame.size.width - textViewFrame.size.width; float increaseY = newTextFrame.size.height - textViewFrame.size.height; // revert the text view size to the size it has before this resize [textView setFrame:textViewFrame]; // resize self to accomodate for the size of the text view NSRect newSelfFrame = [self frame]; newSelfFrame.size.width += increaseX; newSelfFrame.size.height += increaseY; // the minimum size to resize self to is the contentSize of the scroll view NSSize scrollViewContentSize = [scrollViewAncestor contentSize]; if(newSelfFrame.size.width scrollViewContentSize.width) newSelfFrame.size.width = scrollViewContentSize.width; if(newSelfFrame.size.height scrollViewContentSize.height) newSelfFrame.size.height = scrollViewContentSize.height; [self setFrameSize:newSelfFrame.size]; [self setNeedsDisplay:YES]; } //
Custom NSActionCell subclass + table column binding
Hi all, I've made an NSActionCell subclass for indicating the priority of an object, similar to the rating column in iTunes. The visual aspects of it are working fine, as well as displaying the correct priority for table rows that have a priority value set. The problem is setting the new priority when the user clicks on the column. I've tried two approaches: 1) Setting the target of the cell to self, and in the action message set the objectValue of the cell to the desired priority (which I have no problem determining from the location of the mouse click). Somehow that does not affect the bound NSManagedObject at all. 2) Using the mouse tracking approach that I copied from: http://code.google.com/p/fskit/source/browse/trunk/FSKit/Sample%20Apps/FSSearchDemo/SFHFRatingCell.m?r=37 This didn't work either (it also sets the objectValue of the cell)... I guess I am missing something fairly obvious, but I've been searching through the docs for it, and I can't find it. Any help would be greatly appreciated... In IB I bound the table column to the arrangedObjects.priority of the array controller of the table. I have a coordinating controller that initializes and sets the custom cell on the column in it's awakeFromNib. Reading the binding reference for NSTableColumn seems to indicate to me that the cell's objectValue is what gets bound to the managed object's property, so it seems what I am doing should just work, and it just does not. TIA, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[SOLVED] Re: Custom NSActionCell subclass + table column binding
On Sep 10, 2009, at 09:40, BareFeet wrote: Hi Florijan, I've made an NSActionCell subclass for indicating the priority of an object, similar to the rating column in iTunes. The visual aspects of it are working fine, as well as displaying the correct priority for table rows that have a priority value set. The problem is setting the new priority when the user clicks on the column. I've tried two approaches: 1) Setting the target of the cell to self, and in the action message set the objectValue of the cell to the desired priority (which I have no problem determining from the location of the mouse click). Somehow that does not affect the bound NSManagedObject at all. If I understand you correctly, you have bound your table column to an array controller, and are trying to change the data by changing the table column. As far as I understand bindings (which isn't much), you aren't supposed to (because it won't work) change the data by programmatically adjusting the view (ie the table column cell). This makes sense, though it is unfortunate. I was hoping to somehow be able to do it this way so that virtually all of the logic would be encapsulated in my cell class, without the need for it to know much about objects outside of it. I suppose the other example that I found of this type of a table column cell was not used with bindings, and consequently this approach worked... You should instead direct any programmatic changes to the data itself, through the controller in a key-value compliant way. Then the view will automatically reflect those changes. I hope this helps. If ou need more detail, I'll try to follow up. I am able to do this. I am not sure it is flawless, but it works as far as I have tested it. I am not too happy about it as it scatters the logic a bit, but it works. Thanks for your help, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextView resizeability and scrolling
Hi Ross, Thanks for your reply, On Sep 09, 2009, at 13:15, Ross Carter wrote: I've googled for a solution, found nothing. I tried making it by observing the NSViewFrameChangedNotification of the NSTextView from it's parent, and resizing, but this is more tricky then I imagined. I think you are on the right track. You might want to look at these threads: http://www.cocoabuilder.com/archive/message/cocoa/2009/4/24/235290 http://www.cocoabuilder.com/archive/message/cocoa/2009/3/16/232453 I took a look. The code you posted in the second thread (having a switch to stop recursive resizing) makes sense. I was thinking along similar lines. At the bottom I pasted my current code on this. There is a problem though, but one which seems to be connected to having an NSTextView not directly embedded in a scroll view, not so much with my code... In short, NSTextView does not react to the parent view resizing in the standard way (which is easily tested in IB). Perhaps it assumes it is directly embedded in a scroll view. This makes it hard to reconcile with what I am trying to do, even if my added code works OK. Any thoughts? As as side question, it seems that an NSTextView has some margins that separate the text from it's outer edges. This makes sense when the NSTextView is in an NSScrollView, but makes it difficult to align the text view when it is not. I can't find any documented API on controlling this. Is it possible? I think you want to look at setLineFragmentPadding: in NSTextContainer. That sounds like the right thing, thanks... F @interface FSEmbeddedTextView2 : NSView { IBOutlet NSTextView* textView; NSRect textViewFrame; BOOL isChangingFrameSize; } @end @implementation FSEmbeddedTextView2 -(void)awakeFromNib { NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; textViewFrame = [textView frame]; [nc addObserver:self selector:@selector(embeddedTextViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:textView]; } -(void)embeddedTextViewFrameDidChange:(NSNotification*)n { // if the resize of the text view is happening during a resize of this view // then it is autosizing at work, and we can ignore it if(isChangingFrameSize){ textViewFrame = [textView frame]; return; } // figure out the size change in the text view NSRect newTextFrame = [textView frame]; float increaseX = newTextFrame.size.width - textViewFrame.size.width; float increaseY = newTextFrame.size.height - textViewFrame.size.height; // reset the text view to where we started [textView setFrame:textViewFrame]; // resize this view, which will autosize the text view to the new size // which can accommodate all the text NSRect newSelfFrame = [self frame]; newSelfFrame.size.width += increaseX; newSelfFrame.size.height += increaseY; [self setFrameSize:newSelfFrame.size]; } -(void)setFrame:(NSRect)newFrame { isChangingFrameSize = YES; [super setFrame:newFrame]; isChangingFrameSize = NO; } -(void)setFrameSize:(NSSize)newSize { isChangingFrameSize = YES; [super setFrameSize:newSize]; isChangingFrameSize = NO; } -(void)dealloc { NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; [nc removeObserver:self name:NSViewFrameDidChangeNotification object:textView]; [super dealloc]; } @end ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSTextView resizeability and scrolling
Hi all, I am trying to make a user interface in which there is a view that contains multiple subviews, one of which is an NSTextView. The parent view should be embedded in an NSScrollView. The idea is that when the NSTextView is typed in, and possibly resizes as a consequence, it's parent view should resize, scroll bars should appear etc. The effect would be similar to what you get in address book when typing in the notes field. If the notes field gets too big, you get to scroll all of the contact info, not only the view. Googling indicates however that this is done differently, I am not searching for a way to imitate this exact behavior, just using it as an example of what I want to achieve visually. I've googled for a solution, found nothing. I tried making it by observing the NSViewFrameChangedNotification of the NSTextView from it's parent, and resizing, but this is more tricky then I imagined. As as side question, it seems that an NSTextView has some margins that separate the text from it's outer edges. This makes sense when the NSTextView is in an NSScrollView, but makes it difficult to align the text view when it is not. I can't find any documented API on controlling this. Is it possible? Perhaps I am going about this the wrong way. I am open to suggestions on how to accomplish this some other way. TIA, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSWindow curved shape antialiasing + shadow
Hi all, I am experimenting with custom shaped NSWindows, that I draw into using NSBezierPath. Generally all is good, but there is a small problem. If the edge of the window is defined by a curve that is antialiased, then the shadow is drawn at the first outside pixel that is not drawn into at all. Resulting in the window edge having consisting of: Opaque pixels - Semitransparent pixels - Opaque shadow line - Shadow falloff This is irritating. I have the possibility of turning of antialiasing for my background shape, resulting in not having semitransparent pixels in between of the opaque background and the opaque shadow line. This is better. However, results in rough curves... I am looking for a way to have both (smooth curves, and a nice shadow). What I am thinking of is putting a window with the same shape, slightly smaller, behind my main window. And then only have the back window draw a shadow, which would hopefully result in something decent. Any thoughts on this? Is there a better solution? Thanks, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Bound NSPopUpButton + null at the beginning
On May 26, 2009, at 16:55, Stamenkovic Florijan wrote: Hi all, I am trying to figure out how to properly accomplish the following, and after reading docs, references and googling, I am still stuck. Any help appreciated: 1. Have an NSPopUp, Contents and Content values bound to an NSArrayController's arrangedObjects and arrangedObjects.name, respectively. 2. Have the window title bound to the NSArrayController selection.name, and have a replacement string in case of no(null) selection, or empty selection 3. Have a selectable null at the beginning of the popup. I have two possible solutions, but both are flawed. 1. Bind the NSPopUp's selected index to NSArrayController's selected index. Use Inserts Null Placeholder in the Contents binding to make sure I get a selectable null at the beginning of the popup. The problem is that if I at some point choose the null in the popup, the window title does not get updated with the replacement string, and I get a log statement: [NSArrayController 0x1340f0 setNilValueForKey]: could not set nil as the value for the key selectionIndex. 2. To work around this, I tried adding an [NSNull null] at the beginning of the NSArrayController's contents array. And deselect the Inserts Null Placeholder in popup's contents binding. This solves the selectionIndex issue, but it introduces a different problem. Now if I select the null in the popup, my window title does not get updated with the replacement string, but with the null text. It seems that [NSNull null] is not seen as something to be replaced with the Null replacement string. I also get a log statement: Cannot create NSArray from object null of class NSNull Is there an elegant way of dealing with this? I am thinking that somehow it should be possible to bind the popup selected value directly to the controller's selection. Then I could use the approach described under (1), but avoid the index issue. However, I can't seem to do that. The Selected object binding of the popup seems to be incompatible with the NSArrayController selection, as the NSArrayController seems to wrap the selection in a proxy. The NSArrayController's selectedObjects deals with NSArrays, not individual values. Perhaps if I used a custom value converter that converts from NSArray* to it's object at 0 index? Or is there a better solution? The value converter approach seems to work OK, in case anyone is interested. I'd still be happy to learn a more concise way to do this, if there is one. F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Bound NSPopUpButton + null at the beginning
Hi all, I am trying to figure out how to properly accomplish the following, and after reading docs, references and googling, I am still stuck. Any help appreciated: 1. Have an NSPopUp, Contents and Content values bound to an NSArrayController's arrangedObjects and arrangedObjects.name, respectively. 2. Have the window title bound to the NSArrayController selection.name, and have a replacement string in case of no(null) selection, or empty selection 3. Have a selectable null at the beginning of the popup. I have two possible solutions, but both are flawed. 1. Bind the NSPopUp's selected index to NSArrayController's selected index. Use Inserts Null Placeholder in the Contents binding to make sure I get a selectable null at the beginning of the popup. The problem is that if I at some point choose the null in the popup, the window title does not get updated with the replacement string, and I get a log statement: [NSArrayController 0x1340f0 setNilValueForKey]: could not set nil as the value for the key selectionIndex. 2. To work around this, I tried adding an [NSNull null] at the beginning of the NSArrayController's contents array. And deselect the Inserts Null Placeholder in popup's contents binding. This solves the selectionIndex issue, but it introduces a different problem. Now if I select the null in the popup, my window title does not get updated with the replacement string, but with the null text. It seems that [NSNull null] is not seen as something to be replaced with the Null replacement string. I also get a log statement: Cannot create NSArray from object null of class NSNull Is there an elegant way of dealing with this? I am thinking that somehow it should be possible to bind the popup selected value directly to the controller's selection. Then I could use the approach described under (1), but avoid the index issue. However, I can't seem to do that. The Selected object binding of the popup seems to be incompatible with the NSArrayController selection, as the NSArrayController seems to wrap the selection in a proxy. The NSArrayController's selectedObjects deals with NSArrays, not individual values. Perhaps if I used a custom value converter that converts from NSArray* to it's object at 0 index? Or is there a better solution? Sorry if this is something obvious, but I am missing it. Thanks in advance, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[SOLVED] Re: Newbie question on listing out detailed items
Graham, Jason, Thanks for your replies. What I want: a listout of items, each of which presents info and a number of controls. Typical example: Safari's downloads window. ... Any pointers to documentation on how to deal with this would be very appreciated. Perhaps I am simply using the wrong terms to search. You might like to check out Joar Wingfors' Subview-Tableview example. I believe it does almost exactly what you want: http://joar.com/code/ There is also AMCollectionView from Andreas Mayer that is similar: http://www.harmless.de/cocoa-code.php Both of these seem to address exactly what I want to do. On first glance I like AMCollectionView's API a bit better, but I will check both of them out. Thanks! F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Newbie question on listing out detailed items
Hi all, Maybe this has been answered before, if so I am sorry to pollute. I've googled the archives, looked through CocoaDev, went through the documentation, and was not able to figure this out. Also I must say that I am a complete beginner in Cocoa. I just finished Aaron Hillegass's book Cocoa programming for Mac OSX, and am trying to tackle more complex issues to improve my skills. What I want: a listout of items, each of which presents info and a number of controls. Typical example: Safari's downloads window. I figured out (more or less) how to use NSCollectionView to accomplish this. The problem is the annoying animation (and I read somewhere it can't be turned off), which also occasionally introduces bad rendering. So I am trying to figure out an alternative way, that was used prior to 10.5. NSTableView does not seem to be of much help. It accepts an NSCell as means of rendering, but if I understand it correctly, an NSCell can't contain subviews nor subcells, and is therefore of little use. Any pointers to documentation on how to deal with this would be very appreciated. Perhaps I am simply using the wrong terms to search. Thanks in advance, F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com