Self KVO...

2014-10-09 Thread Randy Widell
I’m not sure I am having a hard time figuring this out and I am just not 
finding anything via Google.  I am writing a NSTextFieldCell subclass and I 
want to recalculate the size whenever the string value changes via a binding.  
What I can’t seem to figure out is how to observe the change.  I could register 
each instance with itself for change notifications, but that just seems like an 
odd way to go about it.  Seems like it should be possible to just override 
setValue:forKeyPath:, but that never seems to be called.

Any suggestions would be welcome.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Self KVO...

2014-10-09 Thread Randy Widell

> On Oct 9, 2014, at 21:13, Ken Thomases  wrote:
> 
> On Oct 9, 2014, at 10:56 PM, Randy Widell  wrote:
> 
>> I’m not sure I am having a hard time figuring this out and I am just not 
>> finding anything via Google.  I am writing a NSTextFieldCell subclass and I 
>> want to recalculate the size whenever the string value changes via a 
>> binding.  What I can’t seem to figure out is how to observe the change.  I 
>> could register each instance with itself for change notifications, but that 
>> just seems like an odd way to go about it.  Seems like it should be possible 
>> to just override setValue:forKeyPath:, but that never seems to be called.
> 
> I would expect that the control will call -setObjectValue: on the cell when 
> it (the control) receives a new value via the binding.
> 
> It may not be the case that the control ever gets -setValue:forKey: when the 
> property to which it is bound changes.  That's one possible way for the 
> implementation to work, but as least as likely is for the control to have 
> -observeValueForKeyPath:… to be called on it because it was using KVO to 
> observe the property to which it is bound.
> 
> In any case, the cell should be entirely insulated from the way in which the 
> control received its new value.  When implementing a cell, you should not 
> need to care about bindings or whatever.
> 
> Regards,
> Ken
> 

Oh, man, thanks.  I knew it had to be something straightforward.  Yeah, the 
whole KVO route seemed like a weird way to go about it.  Went down the wrong 
rabbit hole.  Thanks!
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Clear NSSearchField

2014-10-18 Thread Randy Widell
It looks like a couple of people have asked about this in the past, but none of 
the answers are working for me.  I am trying to clear the contents of a 
NSSearchField and have it go back to its empty state.  I don’t have a 
pre-Yosemite Mac handy to check if this is a bug / new behavior in Yosemite, 
however Apple Mail seems to be able to do it just fine.

Most of the solutions I have seen are old and center around doing things like:

[[searchField.cell cancelButtonCell] performClick: self];

…or...

searchField.stringValue = @“”;
[searchField validateEditing];

Both of these methods do clear the NSSearchField’s string value, however the 
Cancel button remains visible and the search field does not go back to its 
empty state (magnifying glass centered, gray “Search” text placeholder, and 
Cancel button not visible).

I have had some marginal success by modifying outlineViewSelectionDidChange: to 
set the search field’s stringValue to @“”, do what needs to be done to update 
the other views, set the search field to the first responder, and then set the 
outline view back to the first responder.

That works somewhat, but not really.  Half the time the search field remains 
the first responder as if the call to set the outline view as the first 
responder never happened.

Any ideas?
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Clear NSSearchField

2014-10-18 Thread Randy Widell
Yeah, I tried that initially.  An invalid parameter exception comes flying out 
of NSCell’s setStringValue.


> On Oct 18, 2014, at 14:59, Gerd Knops  wrote:
> 
> Did you try to set it ti nil instead of an empty string?
> 
> Gerd
> 
>> On Oct 18, 2014, at 4:51 PM, Randy Widell  wrote:
>> 
>> It looks like a couple of people have asked about this in the past, but none 
>> of the answers are working for me.  I am trying to clear the contents of a 
>> NSSearchField and have it go back to its empty state.  I don’t have a 
>> pre-Yosemite Mac handy to check if this is a bug / new behavior in Yosemite, 
>> however Apple Mail seems to be able to do it just fine.
>> 
>> Most of the solutions I have seen are old and center around doing things 
>> like:
>> 
>>  [[searchField.cell cancelButtonCell] performClick: self];
>> 
>> …or...
>> 
>>  searchField.stringValue = @“”;
>>  [searchField validateEditing];
>> 
>> Both of these methods do clear the NSSearchField’s string value, however the 
>> Cancel button remains visible and the search field does not go back to its 
>> empty state (magnifying glass centered, gray “Search” text placeholder, and 
>> Cancel button not visible).
>> 
>> I have had some marginal success by modifying outlineViewSelectionDidChange: 
>> to set the search field’s stringValue to @“”, do what needs to be done to 
>> update the other views, set the search field to the first responder, and 
>> then set the outline view back to the first responder.
>> 
>> That works somewhat, but not really.  Half the time the search field remains 
>> the first responder as if the call to set the outline view as the first 
>> responder never happened.
>> 
>> Any ideas?
>> ___
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/gerti-cocoadev%40bitart.com
>> 
>> This email sent to gerti-cocoa...@bitart.com
> 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Clear NSSearchField

2014-10-18 Thread Randy Widell
Yeah, that doesn’t work either.  I’m clearing the search field in response to a 
change in selection in an outline view.  Which means the search field is 
already not the first responder.  So, setting the first responder to nil just 
makes the outline view give up first responder without affecting the search 
field.


> On Oct 18, 2014, at 15:19, Kyle Sluder  wrote:
> 
> On Sat, Oct 18, 2014, at 04:51 PM, Randy Widell wrote:
>> That works somewhat, but not really.  Half the time the search field
>> remains the first responder as if the call to set the outline view as the
>> first responder never happened.
> 
> Have you tried forcing the text field to give up first responder via
> [textField.window makeFirstResponder:nil] ?
> 
> --Kyle Sluder
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/randy.widell%40gmail.com
> 
> This email sent to randy.wid...@gmail.com


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Toolbar icons, yosemite

2014-10-18 Thread Randy Widell
1) This is pretty easy.  Just create a Pop Up Button, then switch its style to 
“Pull Down”.  This will give you a push button with the single down arrow on 
the right.  Then just edit the Pop Up Button’s menu.  You can give it an icon, 
and then size it down horizontally so that only the icon is visible.

2) I was actually looking for this the other day.  I found this site…  
http://flaticons.net/   The have some pretty good 
two-color, flat icons that you can use to make template images for toolbars.


> On Oct 18, 2014, at 15:12, Alex Kac  wrote:
> 
> I’m learning about toolbar buttons/icons on Yosemite (probably not much 
> different than before, but…I’m an iOS guy so its new for me). I have a few 
> basic, 101-style questions that I hope somebody can point me to the right 
> place for:
> 
> 1. How do you do a popup menu button like the sidebar icon within Preview or 
> other system apps?
> https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0
> 
> 2. Does anyone have a good set of assets either free or for purchase for 
> non-system provided, but standard icons like the sidebar icon used in Preview 
> and in other places throughout OS X?
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/randy.widell%40gmail.com
> 
> This email sent to randy.wid...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Toolbar icons, yosemite

2014-10-18 Thread Randy Widell
Sorry, forgot that giving the Pop Up Button an icon isn’t exactly 
straightforward.  You want to create an menu item at the top of the menu that 
has the icon but no text.  Then add the rest of your menu items below it.  The 
Pop Up Button will display with the icon, but the first menu item will not 
display in the menu during run time.


> On Oct 18, 2014, at 17:31, Randy Widell  wrote:
> 
> 1) This is pretty easy.  Just create a Pop Up Button, then switch its style 
> to “Pull Down”.  This will give you a push button with the single down arrow 
> on the right.  Then just edit the Pop Up Button’s menu.  You can give it an 
> icon, and then size it down horizontally so that only the icon is visible.
> 
> 2) I was actually looking for this the other day.  I found this site…  
> http://flaticons.net/ <http://flaticons.net/>  The have some pretty good 
> two-color, flat icons that you can use to make template images for toolbars.
> 
> 
>> On Oct 18, 2014, at 15:12, Alex Kac mailto:a...@webis.net>> 
>> wrote:
>> 
>> I’m learning about toolbar buttons/icons on Yosemite (probably not much 
>> different than before, but…I’m an iOS guy so its new for me). I have a few 
>> basic, 101-style questions that I hope somebody can point me to the right 
>> place for:
>> 
>> 1. How do you do a popup menu button like the sidebar icon within Preview or 
>> other system apps?
>> https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0
>>  
>> <https://www.dropbox.com/s/37ec5us2f91j0k3/Screenshot%202014-10-18%2016.12.49.png?dl=0>
>> 
>> 2. Does anyone have a good set of assets either free or for purchase for 
>> non-system provided, but standard icons like the sidebar icon used in 
>> Preview and in other places throughout OS X?
>> ___
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/randy.widell%40gmail.com
>> 
>> This email sent to randy.wid...@gmail.com
> 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Toolbar icons, yosemite

2014-10-18 Thread Randy Widell
> 
> I second this site. It’s really useful for finding icons. Just be warned that 
> some of them don’t look like Apple icons and may feel out of place, even with 
> the new flat design style.
> 

Agreed.  They work well for the application I am working on, but, yeah, that 
might not be the case for him.  I should have just posted this:  
http://mashable.com/2013/08/14/flat-design-icons/ 


Pretty much everything you could want there, including some Apple-native 
looking stuff.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Swift program termination...

2015-05-24 Thread Randy Widell
I’m messing around with Swift to create a network server daemon.  Maybe I am 
thinking too much like a C / C++ programmer, but I am trying to figure out how 
to gracefully exit when launchd unloads the daemon.  Normally, you would just 
trap SIGTERM, but I’m just not finding anything online about how to do 
something similar in Swift.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift program termination...

2015-05-24 Thread Randy Widell
Ah, interesting.  I'll give that a shot, thanks.

> On May 24, 2015, at 08:58, Stephen J. Butler  wrote:
> 
> I think you should use GCD by creating a dispatch source of type
> DISPATCH_SOURCE_TYPE_SIGNAL (the handle is the signal enum, eg
> SIGTERM), add an event handler, and then resume it.
> 
>> On Sun, May 24, 2015 at 10:40 AM, Randy Widell  
>> wrote:
>> I’m messing around with Swift to create a network server daemon.  Maybe I am 
>> thinking too much like a C / C++ programmer, but I am trying to figure out 
>> how to gracefully exit when launchd unloads the daemon.  Normally, you would 
>> just trap SIGTERM, but I’m just not finding anything online about how to do 
>> something similar in Swift.
>> ___
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/stephen.butler%40gmail.com
>> 
>> This email sent to stephen.but...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift program termination...

2015-05-26 Thread Randy Widell
Hey, thanks for the idea.  After some stumbling through documentation and other 
posts, I got it working.  The two biggest problems were finding a way to define 
SIG_IGN to prevent default handling of the signal, and I didn’t know that I had 
to use a global queue with a custom run loop or use dispatch_main.

So, for the record...

import Foundation

let SIG_IGN = CFunctionPointer<((Int32) -> Void)>(COpaquePointer(bitPattern: 1))

signal(SIGINT, SIG_IGN)
signal(SIGTERM, SIG_IGN)

var queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0)

var done = dispatch_semaphore_create(0)

var SIGINTsrc = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, 
UInt(SIGINT), 0, queue)
dispatch_source_set_event_handler(SIGINTsrc) {
println("Trapped SIGINT!")
dispatch_semaphore_signal(done)
}
dispatch_resume(SIGINTsrc)

var SIGTERMsrc = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, 
UInt(SIGTERM), 0, queue)
dispatch_source_set_event_handler(SIGTERMsrc){
println("Trapped SIGTERM!")
dispatch_semaphore_signal(done)
}
dispatch_resume(SIGTERMsrc)

do
{
var wait = dispatch_time(DISPATCH_TIME_NOW, 10)

if (dispatch_semaphore_wait(done, wait) == 0)
{
break
}
} while(true)


> On May 24, 2015, at 09:58, Randy Widell  wrote:
> 
> Ah, interesting.  I'll give that a shot, thanks.
> 
>> On May 24, 2015, at 08:58, Stephen J. Butler  
>> wrote:
>> 
>> I think you should use GCD by creating a dispatch source of type
>> DISPATCH_SOURCE_TYPE_SIGNAL (the handle is the signal enum, eg
>> SIGTERM), add an event handler, and then resume it.
>> 
>>> On Sun, May 24, 2015 at 10:40 AM, Randy Widell  
>>> wrote:
>>> I’m messing around with Swift to create a network server daemon.  Maybe I 
>>> am thinking too much like a C / C++ programmer, but I am trying to figure 
>>> out how to gracefully exit when launchd unloads the daemon.  Normally, you 
>>> would just trap SIGTERM, but I’m just not finding anything online about how 
>>> to do something similar in Swift.
>>> ___
>>> 
>>> 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:
>>> https://lists.apple.com/mailman/options/cocoa-dev/stephen.butler%40gmail.com
>>> 
>>> This email sent to stephen.but...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Key equivalents for non-menu items

2011-02-15 Thread Randy Widell
I am trying to wrap my mind around something and the Apple docs are just 
not helping.  I am not sure if I am looking in the wrong places or what, 
but I am just not getting it.


Binding a menu item to First Responder and setting a key equivalent for 
the menu item is trivial.


However, what if I want a key equivalent for a command that is not in a 
menu?


I am approaching this from years of Windows experience (which is 
probably part of the problem), so I am looking for something similar to 
an accelerator table.  I essentially duplicated this idea by overriding 
performKeyEquivalent: in a view, iterating through a table looking for a 
key code and modifier flag match, then performing that action.


This "works", but I would have to duplicate this in every view that 
handles that command.


I tried creating a hidden menu with sub-menu items bound to First 
Responder, but this did not work.


Any guidance would be appreciated.
___

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: Key equivalents for non-menu items

2011-02-15 Thread Randy Widell

On 2/15/11 6:11 PM, Kyle Sluder wrote:

On Tue, Feb 15, 2011 at 5:40 PM, Randy Widell  wrote:

I am trying to wrap my mind around something and the Apple docs are just not
helping.  I am not sure if I am looking in the wrong places or what, but I
am just not getting it.

Binding a menu item to First Responder and setting a key equivalent for the
menu item is trivial.

However, what if I want a key equivalent for a command that is not in a
menu?

The canonical answer is, "You make a menu item for it."


I am approaching this from years of Windows experience (which is probably
part of the problem), so I am looking for something similar to an
accelerator table.  I essentially duplicated this idea by overriding
performKeyEquivalent: in a view, iterating through a table looking for a key
code and modifier flag match, then performing that action.

This "works", but I would have to duplicate this in every view that handles
that command.

Would you mind elaborating on the action you're trying to provide a
shortcut for?

I have a view displaying waveforms.  I would like to have a keyboard 
shortcut that tags a location on the waveforms at the location of the 
mouse cursor.  These commands do not make any sense in the main 
menu...they could go there, but they would be clutter.


I just tried adding a context menu to the view's XIB, assigning the key 
equivalents, and assigning the context menu to the view's menu outlet.  
The commands work if you use them via the menu, but the key equivalents 
did not work.  Using a context menu is too slow for the number of tags 
that generally need to be added anyway.


___

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: Key equivalents for non-menu items

2011-02-15 Thread Randy Widell

On 2/15/11 7:49 PM, Graham Cox wrote:

On 16/02/2011, at 2:36 PM, Randy Widell wrote:


I have a view displaying waveforms.  I would like to have a keyboard shortcut 
that tags a location on the waveforms at the location of the mouse cursor.  
These commands do not make any sense in the main menu...they could go there, 
but they would be clutter.


Just override -keyDown: in your view and do whatever you want. Note though that your 
key equivalents can't be command-  because they are processed as menu 
equivalents separately.

That was essentially what I did first; I was hoping for a better way.  
Thanks, though, I'll keep rolling down that path then.

___

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: Key equivalents for non-menu items

2011-02-15 Thread Randy Widell

On 2/15/11 8:20 PM, mlist0...@gmail.com wrote:

On Feb 15, 2011, at 7:36 PM, Randy Widell wrote:


I would like to have a keyboard shortcut that tags a location on the waveforms 
at the location of the mouse cursor.  These commands do not make any sense in 
the main menu...they could go there, but they would be clutter.

Why do you think they wouldn't make sense in the main menu? That's where we put 
them in SoundEdit 16.

A design point: you should not have any operations that can't be invoked using 
a mouse. So you should have a button or menu for these commands of yours.

_murat
Given the number of tags users add over several hundred pages, it is 
much faster to just point with the mouse, hit a key, and have the 
software enter a tag with a default length that can be modified later if 
need be.  If all the keyboard shortcuts for adding/deleting tags and 
paging are single letters/numbers grouped for one hand, that leaves the 
other hand free to point.


They'll go into context menus for sure, but no one would use them in the 
main menu.

___

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


File types...

2012-03-26 Thread Randy Widell
OK, this is killing me…primarily because I have had this working in other 
applications and cannot find the difference between this current application 
and others where it works.

I have an application that opens one file type, and I have the following 
document type declaration (anonymized):

CFBundleDocumentTypes


CFBundleTypeName
My Document Type
CFBundleTypeRole
Editor
LSItemContentTypes

com.MyDomain.MyApp.MyDocumentType

NSDocumentClass
MyDocumentClass



It is a custom UTI, so, of course, I export it:

UTExportedTypeDeclarations


UTTypeConformsTo

public.database

UTTypeDescription
My Document Type
UTTypeIdentifier
com.MyDomain.MyApp.MyDocumentType
UTTypeTagSpecification

public.filename-extension

myextension





I have an assistant that walks the user through setting up a new document.  
When it is time to save the new document, I create a save panel and pass 
setAllowedFileTypes: a one-element array with 
"com.MyDomain.MyApp.MyDocumentType" in it.  When the user types in the file 
name, the save panel correctly adds the extension.

After saving the document, I open it for the user with the document 
controller's makeDocumentWithContentsOfURL:ofType:error:.  I pass it the URL 
and the "com.MyDomain.MyApp.MyDocumentType" UTI.  The document opens correctly 
with the MyDocumentClass object and resources.

Now…everything goes wrong when I try to open a file.  Opening the recently 
saved document just gives the error: "The document '…' could not be opened.  My 
App cannot open files of this type."  If I try to select the file in the open 
panel, the document is just gray.

I have tried creating test apps and they work fine.  My other apps work.  
Clearly, I screwed something up in this project.  I have deleted the document 
type information from the Info.plist and rebuilt it.  I have tried all kinds of 
UTIs.  Etc. etc. etc.  I cannot seem to get the app to recognize that it can 
open these files.

Any help would be appreciated.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: File types...

2012-03-27 Thread Randy Widell
Yup, that was it.  public.data has to be the first item in the array.  I tried:

* public.database (item 0) only: fail.
* public.database (item 0), public.data (item 1): fail.
* no conformance declarations: fail.
* public.data (item 0), public.database (item 1): success.
* public.data (item 0) only: success.

Thanks so much.  That was driving me crazy.

Randy Widell


On Mar 27, 2012, at 7:50 AM, Kyle Sluder wrote:

> On Mar 26, 2012, at 11:14 PM, Randy Widell  wrote:
> 
>> It is a custom UTI, so, of course, I export it:
>> 
>>   UTExportedTypeDeclarations
>>   
>>   
>>   UTTypeConformsTo
>>   
>>   public.database
>>   
> 
> Not sure this will fix your problem, but you haven't declared conformance to 
> a physical UTI. public.database is purely a functional UTI and does not 
> conform to any physical UTIs.
> 
> If your documents are flat files, you need to add public.data to this array; 
> if your documents are packages, you need to add com.apple.package.
> 
> See: 
> http://developer.apple.com/library/mac/DOCUMENTATION/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html
> 
> --Kyle Sluder


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: File types...

2012-03-27 Thread Randy Widell
Eh.  Looks like you're right.  I reconfigured the Info.plist with 
public.database as Item 0 and public.data as Item 1 and it worked this time 
around.  Originally, I added public.data, cleaned and rebuilt, and the files 
were still showing as gray in the open panel.  But, I cannot reproduce that 
again.  So, all is right with the world, I guess.


On Mar 27, 2012, at 9:13 AM, Randy Widell wrote:

> Yup, that was it.  public.data has to be the first item in the array.  I 
> tried:
> 
> * public.database (item 0) only: fail.
> * public.database (item 0), public.data (item 1): fail.
> * no conformance declarations: fail.
> * public.data (item 0), public.database (item 1): success.
> * public.data (item 0) only: success.
> 
> Thanks so much.  That was driving me crazy.
> 
> Randy Widell
> 
> 
> On Mar 27, 2012, at 7:50 AM, Kyle Sluder wrote:
> 
>> On Mar 26, 2012, at 11:14 PM, Randy Widell  wrote:
>> 
>>> It is a custom UTI, so, of course, I export it:
>>> 
>>>  UTExportedTypeDeclarations
>>>  
>>>  
>>>  UTTypeConformsTo
>>>  
>>>  public.database
>>>  
>> 
>> Not sure this will fix your problem, but you haven't declared conformance to 
>> a physical UTI. public.database is purely a functional UTI and does not 
>> conform to any physical UTIs.
>> 
>> If your documents are flat files, you need to add public.data to this array; 
>> if your documents are packages, you need to add com.apple.package.
>> 
>> See: 
>> http://developer.apple.com/library/mac/DOCUMENTATION/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html
>> 
>> --Kyle Sluder
> 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


IBOutlet & NSNumber

2012-10-13 Thread Randy Widell
Quick question…  For some reason I cannot find an answer.

I have a NSWindowController subclass and I want to bind the selection index of 
a NSComboBox to a NSNumber that is an IBOutlet of the NSWindowController 
subclass.  I have a NSNumber object in the window's XIB and the object is 
linked to the outlet in the subclass, but the outlet is always nil.

Is there something special about NSNumber?  Other object types seem to work.

Thanks
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: IBOutlet & NSNumber

2012-10-13 Thread Randy Widell
Wow.  Woah.  OK, sorry my ignorance offends.  What in the world was I trying to 
do…I was trying to bind the selection index of a NSComboBox to a NSNumber 
because the Apple Cocoa bindings document for NSComboBox says the value can be 
bound to a NSNumber.

Using -init didn't seem so nonsensical to me.  It could it init with 0.  It 
could init with NaN.  But, you're right, -init is not listed in the NSNumber 
class reference and that should have been a clue.

Anyway, cool, I just decided to use -indexOfSelectedItem on a NSComboBox outlet 
when the sheet finishes.



On Oct 13, 2012, at 8:52 PM, Ken Thomases  wrote:

> On Oct 13, 2012, at 9:49 PM, Randy Widell wrote:
> 
>> Quick question…  For some reason I cannot find an answer.
>> 
>> I have a NSWindowController subclass and I want to bind the selection index 
>> of a NSComboBox to a NSNumber that is an IBOutlet of the NSWindowController 
>> subclass.  I have a NSNumber object in the window's XIB and the object is 
>> linked to the outlet in the subclass, but the outlet is always nil.
>> 
>> Is there something special about NSNumber?  Other object types seem to work.
> 
> How could that NSNumber be initialized?  It could only be via -init.  A quick 
> test here shows that [[NSNumber alloc] init] returns nil. I.e. it fails, 
> because that's a nonsensical thing to do.
> 
> So is putting an NSNumber in a NIB.  What in the world are you trying to do?  
> In general, it makes no sense to put things other than views or controller 
> objects into NIBs.  NSNumbers are value objects, suitable for the model layer 
> of your app.
> 
> Regards,
> Ken
> 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: IBOutlet & NSNumber

2012-11-21 Thread Randy Widell
Hey, sorry I never responded.  I just completely forgot.

I don't know what was up when I first read your email, but I just took in the 
wrong way I guess.

After reading your second explanation, I understand what you meant about 
NSNumber.  I was trying to bind the NSComboBox index to a NSNumber object 
mainly because the index was only needed temporarily.

Anyway, for the record, I decided that a NSComboBox was really not the correct 
tool for what I wanted to do anyway.  The HIG says the NSComboBox should allow 
the user to enter a custom value and use the values in the list as 
auto-complete suggestions.  Since I do not want to allow custom values, a table 
view with a search box was a much better solution and works great.

With the table view bound to an array controller, all I needed to do was use 
selectedIndexes to index arrangedObjects to get the information I need from the 
user's selection.

Thanks for the help.


On Oct 13, 2012, at 10:38 PM, Ken Thomases  wrote:

> On Oct 13, 2012, at 11:17 PM, Randy Widell wrote:
> 
>> Wow.  Woah.  OK, sorry my ignorance offends.
> 
> I didn't express offense.  At least, I didn't intend to.
> 
>> What in the world was I trying to do…I was trying to bind the selection 
>> index of a NSComboBox to a NSNumber because the Apple Cocoa bindings 
>> document for NSComboBox says the value can be bound to a NSNumber.
> 
> It can be bound to a _property_ of some object where the type of that 
> property is NSNumber.
> 
>> Using -init didn't seem so nonsensical to me.  It could it init with 0.  It 
>> could init with NaN.  But, you're right, -init is not listed in the NSNumber 
>> class reference and that should have been a clue.
> 
> Well, more to the point: an NSNumber is immutable.  It can only have the 
> value it was initialized with.  So, if you instantiate one in a NIB, whether 
> it got a value of 0 or NaN, it would be stuck with that value forever.
> 
> So, my point was: what good is it to bind a view's selection (or whatever) to 
> a constant value?
> 
> 
>> Anyway, cool, I just decided to use -indexOfSelectedItem on a NSComboBox 
>> outlet when the sheet finishes.
> 
> That works, but it would also have worked to bind the value binding of the 
> NSComboBox to a property of some controller object.  My concern is that you 
> were trying to bind it to an object (rather than a property of an object) 
> which betrays a fundamental confusion, and I wanted to bring that out into 
> the open so you could work through it.
> 
> Regards,
> Ken
> 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSArrayController KVO question...

2012-11-21 Thread Randy Widell
Searching around the Internet, I see a lot of questions and answers about how 
to observe changes to properties of objects in a NSArrayController.  Everything 
I have seen, though, relates to a third object doing the observing.  For 
instance:

 [arrayController addObserver: viewObject forKeyPath: 
@"arrangedObjects.someProperty" ... ]

I am trying to do something similar, but I want to notify the array controller 
itself.

I have an array controller that drives a table view, enables/disables an action 
button, and updates check marks for menu items in the action button's drop down 
menu.  That all works fine.

When I select an action, I want to change a property and update all of the 
array controller's bindings (update the table view to reflect the change, 
update the drop down menu's check mark).  For example, I have an "archive" 
action that should update the item's cell in the table view to display the 
"archived" graphic and "Archive" should be checked in the drop down menu.

I followed the Hillegass example of adding an observer whenever an item is 
added to the array controller and removing the observer whenever an item is 
removed from the array controller.  So, I have...

 - (void) startObserving: (id) object
 {
   [object addObserver: arrayController forKeyPath: @"someProperty" ... ];
 }

 - (void) stopObserving: (id) object
 {
   [object removeObserver: arrayController forKeyPath: @"someProperty" ... ];
 }

The idea being that the array controller is notified whenever someProperty 
changes.  However, nothing happens when I change the property.

I used my window controller as the observer instead of the array controller, 
added an observeValueForKeyPath:... method and verified that changing the 
property of an object does, in fact, trigger an observeValueForKeyPath:... call.

So, two questions: 1) is it even the correct approach to have the array 
controller observe changes in order to update bindings?, 2) if it is, is there 
something I am missing?
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController KVO question...

2012-11-21 Thread Randy Widell
Hmm.  Well, I am updating the model (and the database that backs it).  I just 
need the UI to reflect it.

I guess I was assuming that NSArrayController would respond to a value 
observation the same way it responds to, for instance, a selection change in 
the table view (updates the menu item's check mark).

So, if the window controller has to catch the observation, what's the proper 
way to have the array controller update the UI?

I tried removing the objects affected and adding them back in with the changed 
value which resulted in some weirdness while iterating over selectedObjects.  
Not sure I want to re-query the database to update the full contents of the 
array controller either...unless it's necessary.



On Nov 21, 2012, at 13:46, "jonat...@mugginsoft.com"  
wrote:

> 
> On 21 Nov 2012, at 20:42, Randy Widell  wrote:
> 
>> Searching around the Internet, I see a lot of questions and answers about 
>> how to observe changes to properties of objects in a NSArrayController.  
>> Everything I have seen, though, relates to a third object doing the 
>> observing.  For instance:
>> 
>> [arrayController addObserver: viewObject forKeyPath: 
>> @"arrangedObjects.someProperty" ... ]
>> 
>> I am trying to do something similar, but I want to notify the array 
>> controller itself.
>> 
>> I have an array controller that drives a table view, enables/disables an 
>> action button, and updates check marks for menu items in the action button's 
>> drop down menu.  That all works fine.
>> 
>> When I select an action, I want to change a property and update all of the 
>> array controller's bindings (update the table view to reflect the change, 
>> update the drop down menu's check mark).  For example, I have an "archive" 
>> action that should update the item's cell in the table view to display the 
>> "archived" graphic and "Archive" should be checked in the drop down menu.
>> 
>> I followed the Hillegass example of adding an observer whenever an item is 
>> added to the array controller and removing the observer whenever an item is 
>> removed from the array controller.  So, I have...
>> 
>> - (void) startObserving: (id) object
>> {
>>  [object addObserver: arrayController forKeyPath: @"someProperty" ... ];
>> }
>> 
>> - (void) stopObserving: (id) object
>> {
>>  [object removeObserver: arrayController forKeyPath: @"someProperty" ... ];
>> }
>> 
>> The idea being that the array controller is notified whenever someProperty 
>> changes.  However, nothing happens when I change the property.
>> 
>> I used my window controller as the observer instead of the array controller, 
>> added an observeValueForKeyPath:... method and verified that changing the 
>> property of an object does, in fact, trigger an observeValueForKeyPath:... 
>> call.
>> 
>> So, two questions: 1) is it even the correct approach to have the array 
>> controller observe changes in order to update bindings?, 2) if it is, is 
>> there something I am missing?
>> ___
> Do you really want to update the arrayController bindings rather than update 
> the model?
> If you want to have the tableview reflect the model's archive property then 
> set it on the model.
> 
> The reason your observation isn't working is because the KVO notification is 
> being sent to the NSArrayController instance and it's default implementation 
> of - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
> change:(NSDictionary *)change context:(void *)context (if it exists) will 
> ignore it . You would have to subclass NSArrayController.
> 
> The window controller implementation works because you can catch - 
> (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
> change:(NSDictionary *)change context:(void *)context.
> 
> There is no reason not to let the window controller catch the observation and 
> reconfigure the NSArrayController accordingly.
> 
> Regards
> 
> Jonathan Mitchell
> Mugginsoft LLP
> 
> 
> KosmicTask - the Integrated Scripting Environment for OS X.
> http://www.mugginsoft.com/KosmicTask
> 
> ___
> 
> 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

Re: NSArrayController KVO question...

2012-11-22 Thread Randy Widell
Right, and in other places it works for me.  For instance, I have a window with 
text fields bound to a model object through an object controller.  Updating 
properties of the model updates the text fields.

Reading your test below, one thing I was forgetting is that I am not binding a 
column in the table view to any specific property.  I have one column bound to 
arrangedObjects and a custom cell that draws all the information (think Apple 
Mail with the subject line and then a snippet below).  So, I guess it does make 
sense that the table view does not update.  Perhaps reloadData after I change 
the item.

The menu item's state property is bound to the archive property of 
selectedObjects.  Seems like that should update appropriately.  The only 
difference between that and your test is that I am not using an external array. 
 I am just receiving the action from the menu item, then iterating over 
selectedObjects and changing the property on each.



On Nov 22, 2012, at 1:36, "jonat...@mugginsoft.com"  
wrote:

> On 21 Nov 2012, at 22:19, Randy Widell  wrote:
> 
>> Hmm.  Well, I am updating the model (and the database that backs it).  I 
>> just need the UI to reflect it.
> Hmm, that sounds wonky.
> The whole point of binding is that you can update your model and have your UI 
> reflect the change without any other intervention.
> Is this occurring or not?
> 
> Say you have a model M with properties P1 and P2.
> 
> 1. Instantiate an array A of N model M objects.
> 2. Set the content of array controller AC to array A
> 3. Bind table view TV col1 to AC.arrangedObjects.P1 and col2 to 
> AC.arrangedObjects.P2
> 
> Now you should be able to update any model M property and see the changes 
> reflected in the UI and vice versa.
> 
> Regards
> 
> Jonathan Mitchell
> Mugginsoft LLP
> 
> 
> 
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/bornagainslakr%40gmail.com
> 
> This email sent to bornagainsl...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController KVO question...

2012-11-22 Thread Randy Widell
You presume correctly.  Your suggestion makes perfect sense.  I was just 
reading about key dependencies yesterday, but didn't put 2 and 2 together 
because I wasn't think about the way the table view was setup.

Thanks for the help!


On Nov 22, 2012, at 12:16 PM, jonat...@mugginsoft.com wrote:

> On 22 Nov 2012, at 18:57, Randy Widell  wrote:
> 
>> Right, and in other places it works for me.  For instance, I have a window 
>> with text fields bound to a model object through an object controller.  
>> Updating properties of the model updates the text fields.
>> 
>> Reading your test below, one thing I was forgetting is that I am not binding 
>> a column in the table view to any specific property.  I have one column 
>> bound to arrangedObjects and a custom cell that draws all the information 
>> (think Apple Mail with the subject line and then a snippet below).  
> I do much the same in an outline control and everything updates via bindings 
> fine.
> The multi property cell output can be seen here.
> http://www.mugginsoft.com/kosmictask/help/using#task-view-mode
> 
>> So, I guess it does make sense that the table view does not update.  Perhaps 
>> reloadData after I change the item.
> It makes sense.
> I presume you update your custom cell via NSCell -setObjectValue and draw 
> according to the object properties pass in as the argument.
> This is fine for when the table is first drawn but there is no way for the 
> array controller to learn when the model has been updated.
> You are bound to the model, not a model property. This makes sense as the 
> cell state depends on more than one model property .
> You need a way of letting the bindings machinery that the model has been 
> updated.
> 
> What I do is in my model object is to define a bindingObject property that 
> returns self:
> - (id)bindingObject
> {
>   return self.
> }
> 
> I then bind a NSTableView column to 
> arrayController.arrangedObjects.bindingObject.
> 
> Now, in the model, you just set up a dependency between your bindingObject 
> path and the paths that the custom cell is sensitive to (the affectingKeys in 
> the sample below).
> 
> + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
> {
>NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
>if ([key isEqualToString:@"bindingObject"])
>{
>NSSet *affectingKeys = [NSSet setWithObjects:@"name", @"image", 
> @"count", @"hasCount", @"countColor", @"statusImage", @"updating", 
> @"updatingImageIndex", nil];
>keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys];
>}
>return keyPaths;
> }
> 
> Thus, when, in the example above, I change say the count model property 
> -didChangeValueForKey:@"bindingObject" is sent and the cell is redrawn using 
> the new model properties.
> 
> HTH
> 
> Regards
> 
> Jonathan Mitchell
> Mugginsoft LLP
> 
> 
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/bornagainslakr%40gmail.com
> 
> This email sent to bornagainsl...@gmail.com


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSArrayController KVO question...

2012-11-23 Thread Randy Widell
Well, I implemented your method and still had issues.  Turns out the value 
binding for the drop-down menu was a secondary issue.  After implementing your 
method, I could verify that changing the property did, in fact, trigger an 
update in the table.  However, the values never changed in UI.  The object sent 
to setObjectValue: in my cell still had the original values.

Turns out the value binding with the drop-down menu was resetting the property.

I added a read-only property to my model that just returns the property:

  @property (assign) BOOL archived;
  @property (readonly) BOOL isArchived;

  - (BOOL) isArchived
  {
return archived;
  }

Then, I bound the drop-down menu's value property to isArchived instead of 
archived, unchecked "Raises for Not Applicable Keys", and voila.

Everything works like a charm.

All of that said, since this drop-down menu is an "action" menu, it may be 
better to use the title property of the menu to switch the title between 
"Archive" and "Unarchive" rather than display a check mark next to "Archive".

Anyway, thanks again for your help.


On Nov 22, 2012, at 12:16 PM, jonat...@mugginsoft.com wrote:

> On 22 Nov 2012, at 18:57, Randy Widell  wrote:
> 
>> Right, and in other places it works for me.  For instance, I have a window 
>> with text fields bound to a model object through an object controller.  
>> Updating properties of the model updates the text fields.
>> 
>> Reading your test below, one thing I was forgetting is that I am not binding 
>> a column in the table view to any specific property.  I have one column 
>> bound to arrangedObjects and a custom cell that draws all the information 
>> (think Apple Mail with the subject line and then a snippet below).  
> I do much the same in an outline control and everything updates via bindings 
> fine.
> The multi property cell output can be seen here.
> http://www.mugginsoft.com/kosmictask/help/using#task-view-mode
> 
>> So, I guess it does make sense that the table view does not update.  Perhaps 
>> reloadData after I change the item.
> It makes sense.
> I presume you update your custom cell via NSCell -setObjectValue and draw 
> according to the object properties pass in as the argument.
> This is fine for when the table is first drawn but there is no way for the 
> array controller to learn when the model has been updated.
> You are bound to the model, not a model property. This makes sense as the 
> cell state depends on more than one model property .
> You need a way of letting the bindings machinery that the model has been 
> updated.
> 
> What I do is in my model object is to define a bindingObject property that 
> returns self:
> - (id)bindingObject
> {
>   return self.
> }
> 
> I then bind a NSTableView column to 
> arrayController.arrangedObjects.bindingObject.
> 
> Now, in the model, you just set up a dependency between your bindingObject 
> path and the paths that the custom cell is sensitive to (the affectingKeys in 
> the sample below).
> 
> + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
> {
>NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
>if ([key isEqualToString:@"bindingObject"])
>{
>NSSet *affectingKeys = [NSSet setWithObjects:@"name", @"image", 
> @"count", @"hasCount", @"countColor", @"statusImage", @"updating", 
> @"updatingImageIndex", nil];
>keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKeys];
>}
>return keyPaths;
> }
> 
> Thus, when, in the example above, I change say the count model property 
> -didChangeValueForKey:@"bindingObject" is sent and the cell is redrawn using 
> the new model properties.
> 
> HTH
> 
> Regards
> 
> Jonathan Mitchell
> Mugginsoft LLP
> 
> 
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/bornagainslakr%40gmail.com
> 
> This email sent to bornagainsl...@gmail.com


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Question about docs / window controllers...

2012-11-28 Thread Randy Widell
What are the best practices concerning connecting documents and window 
controllers?

I understand that when I pop up a window related to a document, I need to add 
the window controller to the document with addWindowController:.

One thing I am not clear on is how to handle a modal sheet in within that 
window.

So, imagine something like the Mail where you open the settings window and 
adding an account pops up a modal sheet attached to the settings window.  I 
have a similar setup where the modal sheet needs access to the document.

Adding that modal sheet to the document's window controller list and removing 
it when the sheet ends seems to work fine.  I was just wondering if there are 
consequences I am not seeing.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Question about docs / window controllers...

2012-11-28 Thread Randy Widell
Yep.  Cool, thanks.


On Nov 28, 2012, at 10:23 AM, Kyle Sluder  wrote:

> On Wed, Nov 28, 2012, at 10:09 AM, Randy Widell wrote:
>> Ah, ok.  So, just make the sheet another window in the same XIB and use
>> the same window controller.  Makes sense.
> 
> Or in a different nib. It really doesn't matter. Window controllers are
> not mandatory.
> 
> --Kyle Sluder

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Interface Builder changing size of controls...

2008-09-07 Thread Randy Widell
I cannot seem to find any documentation on this behavior and I really do not
understand what Interface Builder is doing and why.  Sometimes, when I add a
control to a window, it automatically sets the control size to "mini."  For
instance, I added a multiline label to a new window to advise the user about
some of the settings.  When I try to add more controls (label, button, text
field), all subsequent controls are automatically set to "mini."
I can go into the Size Inspector and set the control size back to "regular,"
but, without any explanation of why Interface Builder is doing this, it is
quite annoying.  What is even more weird is that the Apple Human Interface
Guidelines say: "Mixing and matching controls of different sizes in the same
window looks strange and makes aligning those controls more difficult."  So,
does anyone know why Interface Builder would do this?
___

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 [EMAIL PROTECTED]


User input while reading document

2008-09-07 Thread Randy Widell
I am writing an application that supports a couple of different document
types.  One of the document types is a subset of another, so I am using the
same document class for both.  When opening the subset type, however, I need
the user to specify a few things about how to import the data.  As for the
superset type, the file may be encrypted, so the user would need to enter a
password.
What is not clear to me is how I would go about prompting the user during
readFromURL.  What is clear, is that application modal dialogs are bad
apparently, and I am cool that.  So, that leaves document modal sheets.
 However, document modal sheets need a window.

So, I am thinking that readFromURL will just do the bare minimum to
determine what the document class needs to know from the user.  I would then
use windowControllerDidLoadNib to determine when the document's main window
and its sheets are valid, bring up the necessary sheet based on what
readFromURL determined, and then call the appropriate function to do the
rest of work reading the file.

Is this a fundamentally sound design?  Is there a better way to do this?
___

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 [EMAIL PROTECTED]


RE: synthesised variables on 64-bit

2008-10-06 Thread Randy Widell
> Are you running the app in the debugger? If you're building a 4-way
> universal binary, then the debugger will always launch the 32-bit
> version of the executable, even if you're using a 64-bit Mac.
> 
> If you want to build the app for 64-bit only, then you have to
> manually set the architectures to "ppc64 x86_64" instead of using a
> pre-set value. Also, Xcode 3.1's debugger doesn't work correctly with
> 64-bit executables. I haven't checked to see if they fixed this bug in
> 3.1.1, but they did work correctly in 3.0.

This brings up a question I had a while ago, but never asked and about which
I forgot.  I tried making a 64-bit app in Xcode 3.0 a while ago and set the
architectures, as you mentioned, to "ppc64 x86_64".  When I ran the app,
sizeof(long) was still 4 on a Core2 Duo running Leopard.  I found a compiler
option called "Use 64-bit Math".  After enabling that, sizeof(long) was 8.
I was never sure if that was correct behavior, but, as I said, I just forgot
about it.

___

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 [EMAIL PROTECTED]