Re: unable to select submenu item

2009-11-18 Thread Keary Suska
On Nov 18, 2009, at 3:45 PM, SRD wrote:

 - (IBAction) readMenuSelection:(id) sender
 { 
   NSMenu *projectMenu = [sender menu];
   NSLog(@projectMenu = %@, projectMenu);
   
   NSMenuItem *menuItem = [sender selectedItem];
   NSLog(@menuItem %@, menuItem);
   NSLog(@hasSubMenu %d, [menuItem hasSubmenu]);
   
   NSMenu *subMenu = [menuItem submenu];
   NSLog(@submenu %@, subMenu);
 
 
 // output below when selecting an item within the submenu.
 2009-11-18 16:29:46.614 test[4968:a0f] projectMenu = NSMenu: 0x100369be0
   Title: ProjectMenu
   Supermenu: 0x0 (None), autoenable: NO
   Items: (
NSMenuItem: 0x100369a80 ,
NSMenuItem: 0x100369d30 Create, submenu: 0x100369c20 (Create),
NSMenuItem: 0x100318200 Load,
NSMenuItem: 0x1003603c0 ,
NSMenuItem: 0x10036a570 Save,
NSMenuItem: 0x10036ab70 Save As ...
)
 2009-11-18 16:29:46.615 test[4968:a0f] menuItem NSMenuItem: 0x100318200 Load

Here your code indicates that the Load menu item was selected, and according 
to everything you show, Load does *not* have a submenu, so everything is 
working as expected, unless you aren't selecting Load, in which case your 
problem isn't the same as you describe.

 2009-11-18 16:29:46.616 test[4968:a0f] hasSubMenu 0
 2009-11-18 16:29:46.617 test[4968:a0f] submenu (null)
 
 My Menu is structured as follows:
 
 NSPopUpButton
   |- Create (NSMenu) - TestItem (NSMenuItem)
   |- Load (NSMenuItem)
   |- Save (NSMenuItem)
   `- Save As (NSMenuItem)


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSUndoManager and runModalForWindow: (again)

2009-11-16 Thread Keary Suska
On Nov 16, 2009, at 10:34 AM, Kevin wrote:

 I searched the archives on this issue and found several posts with the same 
 question with zero responses. Is NSUndoManager simply not supported in a 
 modal window? Can one of the Apple engineers confirm this?
 
 Here's a recap of the problem I'm running into:
 
 I have a simple Core Data app which displays a list of entities in the main 
 window. To create or add new entities, I use a second modal window with a 
 separate managed object context (a scratchpad) so changes can be 
 undone/redone without interfering with the main managed object context.
 
 The editing window is launched using runModalForWindow:. If I make a series 
 of discrete changes in this modal window, doing a single undo results in 
 undoing ALL my changes. Setting the run loop modes of NSUndoManager (obtained 
 from the second managed object context) to contain NSModalPanelRunLoopMode 
 doesn't appear to make any difference.
 
 If I don't launch the window using runModalForWindow: and simply use 
 makeKeyAndOrderFront:, everything works as expected.

Are you sure that you know which NSUndoManager is being called? When not using 
a modal session it is possible that the API simply does the right thing, or 
appears to under certain circumstances. There may be a combination of issues 
involved. My advice would be to make sure that when your modal session is 
active that the undo actions will always use the temporary MOC's undo manager.

Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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 Always Undesirably Selects First Row when It Loses Key Focus

2009-10-25 Thread Keary Suska

On Oct 23, 2009, at 5:46 PM, Grant Erickson wrote:


On 10/23/09 4:38 PM, Kyle Sluder wrote:
On Fri, Oct 23, 2009 at 4:31 PM, Grant Erickson erick...@umn.edu  
wrote:
Unlike the Network table, in my case there is no mandate that an  
item (i.e.
row) always be selected. However, if there are no rows selected,  
when I hit
the tab key to change the key focus from my table to the  
preferences search
field, the table automatically, yet undesirably, selects the first  
row.


Have you bound the table view to an array controller with avoids
empty selection set?


No, there are no associated controller objects or bindings for the  
table.


Does your table allow empty selections?

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings, am I doing right by MVC?

2009-10-23 Thread Keary Suska

On Oct 23, 2009, at 11:52 AM, Paul Bruneau wrote:


But I wonder about my edit fields. They are bound like:

Bind to: File's owner (a NSWindowController subclass)
Controller Key: blank
Model Key Path: door.backset (door is an ivar of the window  
controller--it's the door that the window controller is for. backset  
is just an ivar of the door object)


Does that look ok, or am I skipping another controller that should  
be in there? Skipping controllers is probably one of my most serious  
bad habits that I'm trying to break.


Using an intermediate controller may be a stylistic issue, but your  
approach above is not wrong. If the bound fields are editable, I  
recommend using an intermediate NSObjectController because you will  
get some useful behavior for free, such as -commitEditing and the  
like.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings Driving Me CRAZY. :'(

2009-10-12 Thread Keary Suska


On Oct 12, 2009, at 11:52 AM, Gustavo Pizano wrote:


Ok this is what I have:

1. InvoiceGenViewController.m - Controller for the InvoiceGenView.xib
2. UserListViewController.m - Controller for the UserListView.xib
3. InvoiceEditionViewController.m - Controller for the  
InvoiceEditionView.xib


InvoiceGenView.xib, has a slipt view and InvoiceGenViewController  
has 2 IBOutlets NSView one for the each view of the split view and  
also has an instance of UserListViewController and  
InvoiceEditionViewController, so when loading the nib, I create  
those controllers with their respective nib files. So far so good.


The UserListView has an IBOutlet NSArrayController with a connection  
in IB to a NSArrayController instance called Users Array. In IB  
for the UserListView.xib, I bind the NSManagedObjectContext  to the  
Files's Owners managedObjectContext, which Im getting form the  
ApplicationDelegate. And I placed a NSTableView with the column  
binding to  Users Array ; controller key :: arrangedObject   ;  
Model Key Path: completeName.
So when the whole window with all  this views loads I can see in  
the ;left side a list of Users, displaying the concatenated name.


Anyway, its working till this point. The problem is that when I  
select an item form the NSTableView(which is in the UserListView), I  
want to display its details in the other view which is controlled by  
InvoiceEditionViewController and it's in another .xib. NO SUCCESS! :(


I have  tried passing the instance of the NSArrayController from  
UserListViewController to InvoiceEditionViewController (IBOutlet  
also) and connecting it to an Instance of NSArrayController in the  
InvoiceEditionViewController.xib (called Ref Users List). Then  
setting the fields bindings to:

Bind : Ref Users List
Controller key : selection
Model Key Path:  firstName  etc for the rest of fields.


This doesn't appear sensible, and you may have a number of problems.  
First, make sure that InvoiceEditionViewController is being  
instantiated properly. Second, simply have a reference to  
UserListViewController in InvoiceEditionViewController, which can be  
an outlet if InvoiceEditionViewController can be sensibly instantiated  
via xib, or set by other means. I recommend then to have an  
NSObjectController in InvoiceEditionViewController.xib whose content  
is bound to UserListViewController.NSArrayController.selection (using  
correct ivar/property names, of course).


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings Driving Me CRAZY. :'(

2009-10-12 Thread Keary Suska

On Oct 12, 2009, at 1:33 PM, Gustavo Pizano wrote:


Keary Hello:



This doesn't appear sensible, and you may have a number of  
problems. First, make sure that InvoiceEditionViewController is  
being instantiated

this is what Im doing: in the awakeFromNib

if(_userListController == nil){
		_userListController = [[UserListViewController alloc]  
initWithNibName:@UserListView bundle:nil];

}
if(_invoiceController == nil){
		_invoiceController = [[InvoiceEditionViewController alloc]  
initWithNibName:@InvoiceEditionView bundle:nil];

}
[_myUserListView addSubview:[_userListController view]];
[_myContentView addSubview:[_invoiceController view]];  
[_invoiceController setUserController:_userListController];


You mentioned having an outlet from the UserListViewController to the  
InvoiceEditionViewController--this can only be accomplished in the  
InvoiceEditionViewController is in the UserListViewController's nib,  
in which case you are instantiating two different  
InvoiceEditionViewControllers and hence experiencing problems.


If the InvoiceEditionViewController is *not* in the  
UserListViewController nib, the above should work fine, except still  
consider the NSObjectController but with the correct key path.


properly. Second, simply have a reference to UserListViewController  
in InvoiceEditionViewController, which can be an outlet if


ok done I have now there this :  IBOutlet UserListViewController *  
userController;


This is only useful if the InvoiceEditionViewController is  
instantiated in the UserListViewController nib, If it is, then chances  
are that the InvoiceEditionViewController is not being instantiated  
correctly unless you have overridden -init or -initWithCoder:,  
depending on the super class.


InvoiceEditionViewController can be sensibly instantiated via xib,  
or set by other means. I recommend then to have an  
NSObjectController in InvoiceEditionViewController.xib whose  
content is bound to  
UserListViewController.NSArrayController.selection (using correct  
ivar/property names, of course).
Ok I tried but when wan tto bind the labels to show the details I  
bind it to the NSObjectControlled I just configured, and the  
controller key goes to selection, which its not good, so whe I run I  
see its NO Selection. label.


No, selection is the correct controller key for data access. It is  
confusing for an object controller as there will only be one selection  
(or none), but that is how it works.


I did instead was to place an NSArrayController (users) in IB and  
bind the contents to   
userController._userListArrayController.arrangedObjects.
then the labels I bind the values to users, and the controller key  
to selection and the path to the attributes of the entity.


And it works 50%, I can see the values., but when I select another  
user, the values dosn't change, it's seems its getting only the 1st  
value of the array.


Of course. You are creating a whole different array controller that  
has its own selection semantics. Bindings are automatic but not magic.  
Scrap the array controller approach. It won't work. Do an  
NSObjectController instead.


Google binding across nibs (you may need to try a few variations on  
the preposition for best results) and you will find numerous  
discussion and techniques.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Help needed with orientation to bindings

2009-09-21 Thread Keary Suska

On Sep 21, 2009, at 6:20 AM, Graham Cox wrote:

So, I have objects that can be selected. None, one or many objects  
might be in the selection. The current selection is available as an  
array property in the base controller (NSWindowController subclass)  
of this particular UI. Each selected object has a dictionary of  
associated data. It is this data I wish to edit via a table view  
with columns for keys and values. This seems like a perfect fit for  
NSDictionaryController. Where I'm having trouble is understanding  
how to deal with multiple selections (that is, multiple dictionaries  
presented by the main selection, not multiple selections in the  
table view - in fact the table view selection is largely unused). If  
there is a single selection, all well and good - looks like  
NSDictionaryController is a good fit out of the box. But for  
multiple selections, I'm less clear. I do need to be able to present  
in the UI effectively a merger of all the selected dictionaries,  
with all keys shown across the selection. Where multiple objects  
have the same key, this is one table row, either showing multiple  
values in the value column for that row, or the value if it's the  
same for all objects. Editing the value sets the values against that  
key for all objects, including adding that key/value to dictionaries  
for selected objects that currently lack it. I'm sort of thinking  
that I need two controllers, a bit like the Attacker/Weapon example  
in the documentation - but I can't be sure because not enough stuff  
is clear in my head, and besides, all the actual selection code is  
handled externally - I just have a -selection property returning the  
objects.


Bindings don't handle aggregate/coalesce. You will need to do that  
yourself in the main or a mediating model. Observe the controller's  
selection (or table view notifications) to update on the fly.


If I can progress on the first part, the next problem is  
representing the data type of the key/value pair. A given key will  
be associated with a definite data type - string, integer, real or  
boolean value. Ideally I'd like to add the appropriate cell type to  
the table row for the 'type' column. My current classically  
implemented UI doesn't do this at all, so this would be a new  
feature. It's very similar to the tables displayed by the plist  
editor application. Looking at NSDictionaryController it seems as if  
the only thing I can do for added values is set a string using - 
setInitialValue:, so I'm not sure how to handle the different data  
types.


Also not a bindings-supported behavior. Implement table view delegate  
methods to provide cells on the fly. You can apply formatters or  
transformers to force default values (if you can't do that at the  
model level).


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: sortedArrayUsingFunction

2009-08-24 Thread Keary Suska

On Aug 24, 2009, at 4:46 PM, Boyd Collier wrote:

The Discussion section in the current documentation for the NSArray  
method sortedArrayUsingFunction: context:
reads The new array contains references to the receiver’s elements,  
not copies of them.  Nothing is said about incrementing the retain  
count of the objects in the array, which seems reasonable.  However,  
some time ago, I copied and pasted what was in Apple's earlier  
documentation into my code, and it read The new array contains  
references to the receiver's elements, not copies of them. The  
retain count is incremented for each element in the receiving  
array. Was the second statement, i.e. that the retain count of each  
element is incremented, an error or has the method itself been  
changed, or am I misunderstanding something (always a strong  
possibility)?



The element objects will be retained by the new array (in addition to  
being retained by the original array). This isn't explicit because it  
is a function of NSArray by definition. Refer to the NSArray API doc  
for this explicitly.


For the sake of accuracy, you should replace every occurrence  
(including in your own brain) of the statement The retain count is  
incremented with A -retain message is sent to. It is possible, and  
not uncommon, that the retain count of an object may never increase or  
decrease, as is the case for singletons. Such an increase or decrease  
should be irrelevant to you in most cases.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?

2009-08-07 Thread Keary Suska


On Aug 7, 2009, at 12:50 PM, Gabriele de Simone wrote:

It used to be that if you overrode -[NSObject  
setValue:forUndefinedKey:] your own subclass was responsible for  
calling -[NSObject will/didChangeValueForKey: so that bindings and  
observers would work as expected.


That was fine, since it allowed one to provide different  
implementations depending on the key, and to generate (or not) KVC  
notifications. It seems that a recent update to Mac OS X (perhaps  
10.5.8?) has changed this behavior. It seems that as long as you  
override setValue:forUndefinedKey:, KVC-compliant notifications are  
automatically generated for the given key.


Can anyone confirm this? This is an interesting change to the  
Cocoa framework that probably interferes with any class that  
overrides [NSObject setValue:forUndefinedKey:].



Calling will/didChange should never have been necessary, and in fact,  
the setter sequence should be automatically wrapped with the calls, as  
long as automatic notification is on. AFAIK, this has always been the  
case and hasn't changed recently. There may be more side effects than  
before, but I don't recall.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Confused about NSPrintInfo margins

2009-07-10 Thread Keary Suska

On Jul 9, 2009, at 7:48 PM, Graham Cox wrote:

Thanks Joel, certainly setting the margins directly does work. What  
I'm left wondering is what they are actually for - they are never  
set by he Page Setup panel and never change with changes to paper  
size, printer, etc.


The docs aren't specific, and it is probably worth filing bugs against  
the docs. It takes some investigating, testing, and looking at sample  
code to get the whole picture.


Page setup only sets five or so settings, listed in the constants  
section of NSPrintInfo. I would never have thought that paper size or  
printer would effect margins, and I am glad that they don't as it  
would lead to highly undesirable behavior. Printer maybe because  
different printers have different minimum margins, but unfortunately  
Apple doesn't give us that for free.


Paper size should only be used for its namesake--i.e. to specify the  
dimensions of the physical page and nothing else. In fact, nothing  
else is effected AFAIK, and as you may be seeing.


My conclusion is that these fields are merely a convenience for  
specifying arbitrary user margins, and if you want to use them you  
have to a) add UI to set them and b) make use of them in your code  
somewhere. By default they do nothing, are ignored and have no  
effect whatsoever on printing unless your code decides not to ignore  
them. Unfortunately this is all guesswork as the docs do not discuss  
it anywhere I can find. At the very least I will file a bug asking  
for better documentation on this.


Yes, but a) only though. Perhaps you mean something else by b) but I  
can attest that in fact when you change the margins of an NSPrintInfo  
that any print job using that object will indeed use the specified  
margins.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: MVC....brief question

2009-07-07 Thread Keary Suska

On Jul 7, 2009, at 6:31 AM, Michael de Haan wrote:


+ (NSSet *)keyPathsForValuesAffectingBmi  /* bmi is model Ivar */
{
return [ NSSet setWithObjects:@weight, @height, nil];
}


My question.  I included the above method in the model, as this is  
the only place available. I just wonder if this is correct?


The only appropriate location for the method is the object that has  
all of the referenced properties.



(in a sense it enables the getter bmi. )


Not in any sense, really. It simply tells all observers of bmi that  
bmi has changed every time weight or height changes.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Problem with NSDecimalNumber truncating zeros

2009-07-06 Thread Keary Suska

On Jul 6, 2009, at 2:35 PM, Eric Hermanson wrote:

	NSDecimalNumber *number = [NSDecimalNumber  
decimalNumberWithMantissa:2200LL exponent:-2 isNegative:NO];


This results in a decimal number that is represented both  
internally, and as a string, as


22

instead of the desired

22.00

Because of the functionality I am trying to achieve, I need to know  
the difference between 22 and 22.00, but I can't figure out how to  
get NSDecimalNumber to retain the trailing zeros.  Does anyone have  
advice?


You shouldn't make statements about the internal workings of API  
classes that you really don't understand. Specifically the statements  
about internal representation and truncating are false. That being  
said, if you want to compare the string representations of two  
numbers, then ensure that they are formatted similarly. Hence, use an  
NSNumberFormatter, preferably the same for both numbers.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: User interface validation doesn't work, right?

2009-07-03 Thread Keary Suska

On Jul 2, 2009, at 11:52 AM, Bill Cheeseman wrote:


On Jul 2, 2009, at 12:24 PM, Keary Suska wrote:

Because the two protocols in question are formal protocols, the  
@interface declaration must specify conformance. If it doesn't,  
then no assumption of conformance should be made. Pure and simple.  
Also, protocol conformance is not inheritable in Objective-C.


1. Taking that last point first, the Objective-C 2.0 Programming  
Language document says this: A class is said to conform to a formal  
protocol if it adopts the protocol or inherits from another class  
that adopts it. I believe, without checking, that this was true in  
1.0, also. I take that to mean that protocol conformance is in fact  
inherited. That makes sense, because a protocol is simply a promise  
that certain methods are implemented, and implemented methods are  
inherited by subclasses.


Yeah, I misspoke there. You are absolutely correct.


2. The key question for me is your first point.

The way I work around the lack of automatic validation for buttons  
is this: In my window controller, I implement - 
validateUserInterfaceItem: and declare that my controller conforms  
to the NSUserInterfaceValidations protocol. That's exactly what  
NSDocument does, as I understand it. Since user interface items are  
not automatically validated, I force validation by implementing  
NSWindow's -windowDidUpdate: delegate method so that it loops  
through all subviews of the window calling my controller's - 
validateUserInterfaceItem: protocol method. (I could use something  
other than -windowDidUpdate: to trigger the protocol method if  
efficiency becomes an issue, but at this point doing it every time  
the window updates works just fine. I am aware that Apple is  
struggling with efficiency concerns in automatic validation of  
toolbar items.)


Why not use bindings or KVO? They will likely be much more efficient,  
easier to implement, and provide more control.


Now here's my question for you: In my controller's implementation of  
-validateUserInterfaceItem:, I can either limit the items that I  
enable/disable by checking whether their class is NSButton (which I  
know responds to -action and -setEnabled:, and I can confirm that  
programmatically). Or, instead, I can limit the items by checking  
whether they conform to the NSValidatedUserInterfaceItem protocol.  
If I do the latter, I have to declare a subclass of NSButton and  
declare that it conforms to the protocol because NSButton does not  
itself declare conformance, and of course I have to set the type of  
my buttons to my subclass type in Interface Builder. Either  
technique works (I know because I've already done it), but testing  
for compliance with the NSValidatedUserInterfaceItem protocol  
somehow seems purer to me.


The whole approach seems problematic to me. I would say that you  
should use the API when you can, and work around it only when you  
can't (I am full of ambiguous maxims these days!) I.e., allow menus  
(includes popups) and toolbars and any other object that conforms to  
NSValidatedUserInterfaceItem proper (proper in the Objective-C view,  
as opposed to your view--this has been hashed out enough I won't  
elaborate) to use their automatic validation, and use a home grown  
solution for everything else. The latter solution also preferably  
working with the API rather than around it (e.g. KVO), because you can.


Where would you come out on this question? From your comments, I  
assume you would say I should not subclass NSButton and declare it  
as conforming. Then I would have to simply check whether the class  
of an item is the NSButton class. You might also insist that I  
should not name my validation method -validateUserInterfaceItem:,  
but something else such as -updateWindow, because I risk confusing  
people about what my controller really does. In that case, I'm back  
where most Cocoa applications were before Cocoa bindings were  
invented, declaring a custom -updateWindow method and calling it  
from -windowDidUpdate or whatever.


Yes, because as others point out, we don't actually know how (more  
importantly, when) validation is called, so we don't know how to  
duplicate it. I doubt that declaring conformance is sufficient.


I would prefer to do things the NSUserInterfaceValidations way, so  
that I'm ready when Apple gets around to making user interface item  
validation automatic, which I really think it ought to do (with an  
on/off switch). (Apple will probably say I should move on to Cocoa  
Bindings and get over it.)



I would agree with Apple, or as a concession, say use KVO.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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

Re: User interface validation doesn't work, right?

2009-07-02 Thread Keary Suska

On Jul 2, 2009, at 1:48 AM, Bill Cheeseman wrote:

I'm not assuming that it works with all user controls. The  
document I quoted from says it does, explicitly and in detail,  
without qualification. All I asked in my original post is whether  
I'm correct in concluding that in fact buttons don't work that way.  
I understand that you've all confirmed that I'm correct in my  
conclusion. Thanks.


You have to confess that the docs don't say, all user interface items  
conform to the NSValidatedUserInterfaceItem protocol and therefore  
support validation. That is the only true *detailed* and *explicit*  
statement that would indicate such. Anything else is an inference,  
although a reasonable and understandable inference, considering the  
docs in isolation.


Your argument seems to make the case that the problem is precisely how  
the docs are *not* explicit, and therefore allow or encourage an  
incorrect inference. I agree, conditionally.


It doesn't help to refer me to the NSUserInterfaceValidations and  
NSValidatedUserInterface protocol documents, because that's where I  
started. They are ambiguous, and they're very short on explanation.  
In fact, I turned to the User Interface Validation document  
precisely because I was seeking clarification of the protocol  
documents. Telling me to go back and look at the protocol documents  
doesn't help.



Well, looking at the methods that both protocols does shed light on  
their purpose, as was explained by Andy Lee.


In trying to pin down whether buttons also do so, I looked at the  
NSButton Class Reference document and found that it expressly  
conforms to the NSUserInterfaceValidations protocol. I don't  
understand why you say it doesn't.


I defer to Andy's explanation.

I did find it confusing when I read the NSMenuItem and NSToolbarItem  
Class Reference documents, which say that they conform to the other  
protocol, the NSValidatedUserInterface protocol. But this tends to  
suggest that NSButton will work, too, since NSControl, from which  
NSButton inherits, also conforms to the NSValidatedUserInterface  
protocol. It doesn't say so, but Apple's documentation has a long  
history of neglecting to mention all the protocols that a class  
conforms to. I was able to confirm from the NSControl Class  
Reference document, and you can too, that NSControl does implement  
the -action and -tag methods required by the  
NSValidatedUserInterface protocol. So, again, I don't understand why  
you say it doesn't.


It's not a matter of docs, although it would be preferable that the  
docs *do* indicate every protocol. Because the two protocols in  
question are formal protocols, the @interface declaration must specify  
conformance. If it doesn't, then no assumption of conformance should  
be made. Pure and simple. Also, protocol conformance is not  
inheritable in Objective-C. Therefore, neither NSControl, nor  
NSButton, conform to the NSValidatedUserInterface protocol.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSObjectController, content outlet and content object question

2009-07-01 Thread Keary Suska

On Jul 1, 2009, at 8:03 AM, Michael de Haan wrote:

I have previously used the content outlet to establish a connection  
between NSObjectController and its object. Is contentObject an  
alternative way to do the same thing


and the best reply by mmalc:

If you set the contentObject of an object controller, then -- just as
anywhere else in Cocoa -- you're setting one of its properties
(typically an instance variable) and it's then the recipient's
responsibility to look after it.

If you bind the contentObject, they you're telling it to keep it
synchronised with whatever is at the end of the keypath you provided
from the source object.

So, when I emulated the currency converter, with bindings, I was  
surprised when they connected the NSObjectController to the model  
using the content outlet of NSObjectController, as per the above  
discussion. ( What I **expected** (clearly incorrectly) was that, in  
order for the project to work, one would have to bind the view to  
the controller, then bind the controller to the model). So, I was  
puzzled when **both** approaches worked ie binding the view to the  
controller, and **either** binding the controller to the model  
( with keypath self)  OR setting the controller's content to the  
view. (Cntrl-dragging from the controller to the model).


It might well be possible that I am thinking about the bindings  
incorrectly...and in fact all one needs in this case is to bind the  
view( textfield and slider) to the controller with the correct  
keypath, and that the relationship of a controller to it's content  
is the issue I am not completely understanding.


Binding only involves two endpoints (objects). That there are  
additional inter-object connections involved in a design is a design  
issue and not inherent to bindings in any way. So it is irrelevant to  
the view-controller bindings how the controller gets its content, and  
there are multiple ways this can be done.


It appears that you are assuming that bindings involves three objects  
ion an MVC pattern. MVC is a design pattern, bindings are only one way  
to connect objects, such as M-C or V-C, but are not themselves an  
implementation of MVC.



Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Basic KVO question

2009-07-01 Thread Keary Suska

On Jun 29, 2009, at 6:09 PM, Tim Schmidt wrote:

first of all, thanks for reading this. I have a basic KVO question.  
In one of my NIBs I have an NSArrayController and a  
NSSegmentedControl with add/remove segments for the array of said  
controller. Now I want to enable the remove-segment according to the  
controllers canRemove message. I've set the NIB's viewcontroller as  
an observer of the arraycontroller's canobserve property as follows:


[statesController addObserver:self forKeyPath:@canRemove  
options:NSKeyValueObservingOptionNew  
context:PED_CAN_REMOVE_STATE_CONTEXT];



and receive the obligatory change notifications alright, but the  
change dictionary always contains an NSNull instance for the  
NSKeyValueChangeNewKey instead of the NSNumber bool subclass I would  
expect. Am I doing something wrong here?


This is probably due to a known bug that will not likely ever be  
fixed. In your particular case, it doesn't matter, as the value will  
have been changed before you receive the observer message.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: User interface validation doesn't work, right?

2009-07-01 Thread Keary Suska

On Jul 1, 2009, at 3:24 PM, Bill Cheeseman wrote:

For years, the Implementing Validation section of Apple's User  
Interface Validation document has said  the following:


Before it is displayed, a user interface item checks to see if its  
target implements validateUserInterfaceItem:. If it does, then the  
enabled status of the item is determined by the return value of the  
method. You can therefore conditionally enable or disable an item by  
implementing validateUserInterfaceItem: in the target object.


This has never been true. Right?


No, I would say it is usually true, but not always.

My custom window controller implements the action method for a  
button, so it is the button's target, and it also implements - 
validateUserInterfaceItem:, all according to the User Interface  
Validation document. But my -validateUserInterfaceItem: method is  
never called.


Implementing the action method isn't sufficient, BTW. The object must  
also be the current target (i.e. first responder for nil-targeted  
actions, or designated target). Also note that not all user interface  
items do this--they must conform to the NSValidatedUserInterfaceItem  
(or NSUserInterfaceValidations) protocol, which IIRC NSButton does  
not. In fact, I think only menu items and toolbar items do.


If I want it to be called automatically, by analogy to - 
validateMenuItem:, I have to override NSWindow's -update method, by  
analogy to -[NSMenu update]. In my override of -update, I have to do  
for myself what the document claims already happens -- or I have to  
observe NSWindow's -NSWindowDidUpdateNotification. Right?



Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: User interface validation doesn't work, right?

2009-07-01 Thread Keary Suska

On Jul 1, 2009, at 5:27 PM, Bill Cheeseman wrote:

My controller is the target, which according to Apple's  
documentation, and according to my understanding for many years,  
means simply that it implements the button's action method. My  
controller does in fact implement the action method. In addition, my  
controller is in the responder chain, which is demonstrated by the  
fact that the action method, which is connected to the First  
Responder proxy in Interface Builder, executes correctly when I  
click the button. Also, I declare the controller to conform to the  
NSUserInterfaceValidations protocol, which it does because it  
implements the -validateUserInterfaceItem: method. NSButton does  
conform to the NSValidatedUserInterfaceItem protocol, as its header  
file confirms, and it does implement the -action: and -target:  
methods required by that protocol.


So I think you are claiming this works because the documentation  
says so. I'm saying the documentation is wrong because it doesn't  
work. I would love to see a project proving me wrong. Can you show  
me one?



No, I am saying that it works as advertised for objects that it works  
for. NSButton is not one of them, and never has been. You seem to  
assume that all user interface items should, but they don't, and never  
have, and the documentation has never said that they did. The  
documentation is explicit:


The protocols NSUserInterfaceValidations and  
NSValidatedUserInterfaceItem provide a standard way to validate user  
interface items—that is, to set their state as appropriate for the  
current application context


Validation is not a function of user interface items, it is a function  
of the protocol(s) listed. Neither NSButton, nor any of its parents  
conforms to the protocol, so none of them support validation of this  
kind. Look at NSMenuItem, and you will see that it does, and that your  
validation method will always be called.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: resizing table view programmatically

2009-06-25 Thread Keary Suska

On Jun 25, 2009, at 9:47 AM, Daniel Child wrote:

I would like to resize a table view programmatically. I will be  
resizing based on the number of rows (which I know in advance),  
given a fixed row height which I set myself.


I tried resizing the window's contentView and that did not work. I  
know that a window, a scroll view, and a clip view are all involved,  
and sizing all of these manually seems like the wrong approach.


What is the easiest way to get the window and table to resize based  
on a calculated number of rows and fixed row height? Is there a  
simple approach that avoids resizing each individual view?


Just resize the window, as long as the scrollview resize flags are set  
to resize with the window. That should be all there is to it.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSArrayController's add: swaps entire content array when array is accessed via keypath

2009-06-25 Thread Keary Suska

On Jun 25, 2009, at 8:31 AM, Rick Hoge wrote:

All worked fine, except that, when the new dictionaries are added by  
clicking the add: button, the mutable array managed by the  
controller is replaced with a new array (rather than inserting the  
new dictionary in the original array).  The new array has the  
correct content, apparently having copied all the pre-existing  
dictionaries from the old array.


This would be ok, except that I observe changes to  
topLevelDictionary.subArray (see below) and need to perform special  
processing on new items inserted in the subArray.  This only works if


-observeValueForKeyPath:ofObject:change:context:

is called with a change type of NSKeyValueChangeInsertion, and I can  
access the inserted items using


 [change valueForKey:NSKeyValueChangeNewKey]

I confirmed that if subArray is promoted to an instance variable,  
then add: will perform an insertion rather than creating a new array  
(in fact I've used this a lot in the past).  It seems that having  
the array be part of a mutable compound object results in creation  
of a new, copied array instead of an insertion.


There are a number of ways I can work around this, but I don't  
really understand why this difference in behavior (array accessed as  
instance variable vs. keypath inside compound object) is happening.   
Is this a bug?  or does it make sense in some way?  This all would  
have been really simple if it worked as expected...


I believe your presumption here is incorrect. In both cases, the array  
should be replaced on every change. Only if you implement indexed  
accessors should this be different. Are you instead talking about KVO  
notifications? You could get different kinds of notifications  
depending on certain implementations.


In your example I would expect KVO notifications to be the same. Do  
you implement standard setkey accessors in your instance variable  
test?


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSViewController awakeFromNib and NSTableView numberOfRowsInTableView

2009-06-25 Thread Keary Suska


On Jun 25, 2009, at 7:33 PM, Peter Zegelin wrote:

	I have come across what seems to be a weird situation and can't  
really think of a good solution. I'm relatively new to Cocoa so its  
probably just a simple misunderstanding.


I have a subclass of NSViewController that also acts as the delegate  
for the NSTableView that it controls. This tableview is loaded into  
my main window. I want to be able to hide some columns in the  
tableview and as a result, the number of rows in the tableview will  
vary according to numColumns. ie:


-(int)numberOfRowsInTableView:(NSTableView *)tableView{

return myDataSize/numColumns;
}

Now, I haven't got around to actually varying the number of columns  
in the table yet, but I do have  a property 'numColumns' that I set  
to a reasonable value in awakeFromNib:


- (void)awakeFromNib{

numColumns = 8;
}


Unfortunately my numberOfRowsInTableView is being called 'before'  
awakeFromNib, so initially numColumns = 0 and I get an error  
(myDataSize/numColumns will be infinite).


I always thought awakeFromNib would get called first. But in this  
case not so. So can anyone suggest why, and a workaround?


There is no such guarantee for -awakeFromNib. You either need to set  
the value earlier, or call -reloadData on the table.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: UndoManager for NSApplication

2009-06-16 Thread Keary Suska

On Jun 16, 2009, at 7:45 AM, Reza Farhad wrote:


I would like to have the facility of undoing deleting of a window.
The best way that I thought I could do this is was to use the  
UndoManager belonging of my NSApplication. However when I try to get  
the undoManager for the application by calling:


[ NSApp undoManager ]

I get a nil pointer.
Also I could not see any straight forward way of setting an  
undoManager for a NSResponder.

Any suggestions how I can resolve this issue.


AFAIK, of the NSResponders only NSWindow creates its own  
NSUndoManager. Now, any responder on a window will automatically  
search up the responder chain for an undo manager, so it should  
automatically get the window's.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings and nested preferences

2009-06-16 Thread Keary Suska

On Jun 16, 2009, at 11:25 AM, Andy Klepack wrote:

I'm curious about what patterns exist for binding to nested sets of  
preferences such as a dictionary value at the top level of the user  
defaults. I've seen a couple of questions similar to this, but no  
one appears to have received the definitive answer.


My scenario is that I have an application with several distinct  
modules and I would like each module's preferences to be stored in a  
separate dictionary.


Say the user defaults look like so:
{
 module = {
moduleValue = xyz
 }
}

The module has a nib with a text field that should be bound to the  
moduleValue. I'd like to have it bind to  
sharedUserDefaultsController.values.module.moduleValue. As far as I  
can tell this is not valid. The bindings system thinks that  
'module.moduleValue' is the key in the user defaults to bind to.


This is almost certainly not the case. What makes you think it is?

My second approach was to create an NSObjectController for which the  
content was bound to sharedUserDefaultsController.values.module. I  
then bound the text field to objectController.moduleValue. In this  
case there were problems when the module dictionary did not already  
exist (the object controller's content was null), plus whenever the  
value moduleValue was set it didn't trigger any user defaults  
behavior since it was a modification of nested content and thus  
didn't trigger change notification for defaults themselves.


The most obvious solution is to create a custom object  
(ModuleController) for the nib, create a moduleValue property with  
custom accessors, implement those accessors to interact with the  
user defaults, and then bind the text field to those properties. At  
the same time, that seems pretty code intensive for something I  
suspect is a fairly common design.



The issue is usually not about nested structures, but about the fact  
the plist backing of user defaults does not use mutable objects.  
Therefore, all of your dictionaries are immutable NSDictionary's.  
Unfortunately the NSUserDefualtsController isn't smart enough to deal  
with nested structures, so you have to provide your own intermediary.  
So, this last approach is really (AFAIK) the common pattern for  
dealing with nested structures on user defaults.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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 and tags...

2009-06-07 Thread Keary Suska

On Jun 7, 2009, at 9:54 AM, Scott Andrew wrote:

This may sound like a newbie questions but never had this issue  
before..  I am trying to add a tag ID to an NSOutlineView thats in  
one view controller. In another view controller is a table view. I  
listen to NSOutlineViewSelectionDidChange notifications and fill the  
table based on the selection. This listens to all outline views  
(even the open file panel). So i put a tag id on my NSOutlineView  
and wanted to check for that particular tag. But it always comes up  
0. I have a work around for this by listening for selection changes  
in the tree controller and firing off a notification based on what  
was actually selected.


I am now just curious about the NSOutlineView and the tag field. I  
couldn't find anything that said you couldn't tag a outline or table  
view control.


First off, how are you setting the tag, and what value are you  
setting? How are you checking the tag (show code)? I haven't heard or  
experienced any issues with NSOutlineView and tags, but if you have a  
reducible/reproducible case, you can file a bug.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Searching in NSArray

2009-06-05 Thread Keary Suska

On Jun 5, 2009, at 9:36 AM, Pierce Freeman wrote:


Hi Everyone:

I am most likely overlooking this function, but I just can't seem to  
find it

in the documentation.  I am looking for some way to search an NSArray
listing for one string that is part of multiple objects in the  
array.  This
search then returns the number of objects that contained that string  
in it.
I imagine this would be built into NSArray, so if anyone could steer  
me in

the right direction, it would be greatly appreciated!



There isn't a method for this specific operation. The right direction  
is likely -filteredArrayUsingPredicate:.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: KVO and master-detail NSTableViews

2009-06-04 Thread Keary Suska

On Jun 4, 2009, at 4:24 AM, Stefan Reitshamer wrote:

I'm getting flaky behavior from my KVO code and I'm wondering what  
I'm doing wrong. I can't find any similar examples.


I have a pop-up button and 2 NSTableViews.
The pop-up button selection controls the content of the left  
NSTableView. The left NSTableView's selection controls the content  
of the right NSTableView.


The pop-up button and NSTableViews are bound to separate  
NSArrayControllers.
Each NSArrayController is bound to a separate NSMutableArray  
property in my app controller.
My app controller observes selectionIndex in the pop-up button's  
NSArrayController and selectedObjects in the left NSArrayController.


On startup, the pop-up button is populated, which causes a call to  
observeValueForKeyPath:ofObject:change:context:. This sets the left  
NSMutableArray, which in turn causes another (nested) call to  
observeValueForKeyPath:ofObject:change:context:, which sets the  
right NSMutableArray.


There seems to be a race condition -- sometimes the left table view  
is populated, sometimes the right, sometimes none. Each time I edit  
the nib, the behavior changes.


If your code depends on the order that objects in the nib are  
initialized, this may be the reason for unexpected behavior. Some  
changes to a nib might effect this loading order, which should be  
considered non-deterministic anyway.



Is this a bogus way to implement the dependent NSTableViews?
What's the right way?



If it is not necessary to route all the controller's content through  
the app controller, you may have better luck hooking the controllers  
together. Refer to this: http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSArrayController.html#//apple_ref/doc/uid/NSArrayController-DontLinkElementID_24 


in particular the contentObject binding.

RightTVController contentObject --  
LeftTVController.selection.array_key_path
LeftTVController contentObject ---  
PopUpController.selection.array_key_path


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSMutableURLRequest weirdness!

2009-06-04 Thread Keary Suska

On Jun 4, 2009, at 2:11 PM, Ammar Ibrahim wrote:

Hello, I'm about to bang my head against the wall. Here's the  
situation, I'm
trying to send many requests using the same request object, I have a  
method

which I call frequently, which has  the following piece of code:


This is not all the relevant code, and is insufficient to help. All I  
can say is, are you re-using the same NSURLConnection, just changing  
the request? If so, that wouldn't work. NSURLConnection copies the  
request on initialization.



NSMutableURLRequest *newReq = [[NSMutableURLRequest alloc] init];

[newReq setHTTPMethod:@GET];

[newReq setURL:[NSURL URLWithString:[@/media
stringByAppendingPathComponent:[currentTrack  
objectForKey:@Persistent ID]]

relativeToURL:[self serverBaseUrl]]];

NSURLConnection *connection = [NSURLConnection  
connectionWithRequest:newReq

delegate:self];

if (connection == nil) {

//connection couldn't be created!

NSLog(@Connection couldn't be created: %@, [newReq URL]);

[self startSyncAfterTimeInterval];

}



The first request works, after that it seems to not even send the  
request,

although the server is still responsive! I get the following error:


*Connection failed with error: Error Domain=NSURLErrorDomain  
Code=-1001

UserInfo=0x1397a40 timed out*
___

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/cocoa-dev%40esoteritech.com

This email sent to cocoa-...@esoteritech.com




Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Image (or view ?) not scaling with window

2009-06-03 Thread Keary Suska

On Jun 3, 2009, at 7:45 AM, vinai wrote:

I've run into a case where an image I am creating does not scale  
with its parent window.  Some background - I am trying to create and  
application to process data stored within a file - much like any  
image data with a header.  However, I am not opening anything with a  
standard image format.


I have a selector panel than selected the kind of data I am reading,  
and lets me select the file.  Based on the header information in  
that file, I create a window, view, image, image representation with  
the appropriate parameters, and I can already create the window and  
draw the contents of my file to it.  It does this initial drawing  
properly.


The problem is, when I grab the edge of the window to resize it, the  
image that's drawn to it does not reisze with the parent window.  It  
maintains its original size, and stays centered in the window view.


My initialization code for the GUI elements of that window is  
below.  Is there a flag I am missing somewhere in this, or do I need  
to handle view and image resize updates in another routine ?


What happens when you set image scaling for the NSImageView?

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Detecting when fetch: finishes

2009-06-03 Thread Keary Suska

On Jun 3, 2009, at 5:12 PM, Ulai Beekam wrote:

I have an NSArrayController that, at the request of the user, can be  
given a new fetch predicate. To do that I use the setFetchPredicate:  
method. How can I detect when this predicate has been applied and  
the appropriate fetching is done? I have not come across any  
delegate method for it.


I suspect that this is made tricky because of the following quote  
from the docs under the fetch: method of NSObjectController (which  
by the way is a superclass of NSArrayController):


Beginning with Mac OS X v10.4 the result of this method is deferred  
until the next iteration of the runloop so that the error  
presentation mechanism can provide feedback as a sheet.


So the problem is that it finishes somewhere in the next runloop  
iteration, making it harder to do some custom things after it  
finishes.



There isn't any way that I know that is more work than it is worth.  
Better to do the fetch yourself.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Detecting when fetch: finishes

2009-06-03 Thread Keary Suska

On Jun 3, 2009, at 6:19 PM, Ulai Beekam wrote:

What do you mean do the fetch myself? Do you mean I should not use  
an NSArrayController? That would sound overkill as NSArrayController  
plus its fetch predicate gives me a lot of functionality for free,  
e.g. updating dynamically when underlying objects are added/removed.  
Can you elaborate?


No, you can use the array controller, just have an object that  
provides the controllers content instead of having the array  
controller fetch it itself. Bind the NSArrayController's contentArray  
to the array managed by the object, and turn off prepares content. You  
will still get all the free functionality as long as you always add/ 
delete through the array controller or through KVO-compliant means. If  
you need to watch for insertions/deletions that are performed outside  
of the array controller and it is not practical to route them through  
the object managing the content, you can have it simply observe  
theObjectsDidChange notification. See the docs for how to access the  
changed objects. I think that is all that the controllers do anyway.


I suppose you could call -performSelector:afterDelay: for your  
followup function, playing with delay values until you find one that  
seems to reliably occur after the fetch. I don't know whether this  
approach is deterministic, or how you would handle an error situation.  
Seems altogether better to me to just handle fetching yourself.


I wonder if you can make an NSArrayController subclass, override - 
fetchWithRequest:merge:error: to just call super, and after the call  
(which should be synchronous), call your special post-processing  
method. Just a stab in the dark, but might work.





From: cocoa-...@esoteritech.com
To: cocoa-dev@lists.apple.com
Date: Wed, 3 Jun 2009 17:31:32 -0600
Subject: Re: Detecting when fetch: finishes

On Jun 3, 2009, at 5:12 PM, Ulai Beekam wrote:


I have an NSArrayController that, at the request of the user, can be
given a new fetch predicate. To do that I use the setFetchPredicate:
method. How can I detect when this predicate has been applied and
the appropriate fetching is done? I have not come across any
delegate method for it.

I suspect that this is made tricky because of the following quote
from the docs under the fetch: method of NSObjectController (which
by the way is a superclass of NSArrayController):

Beginning with Mac OS X v10.4 the result of this method is deferred
until the next iteration of the runloop so that the error
presentation mechanism can provide feedback as a sheet.

So the problem is that it finishes somewhere in the next runloop
iteration, making it harder to do some custom things after it
finishes.



There isn't any way that I know that is more work than it is worth.
Better to do the fetch yourself.




Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Keary Suska

On May 31, 2009, at 4:31 PM, Dominik Pich wrote:


Hi,
I use NSXMLParser to parse large XML files-- going good BUT :)
I cant get the parser to resolve the external entities from the DTD.

I googled and read documentation and older mails...
and I did set parser.shouldResolveExternalEntities = YES


Well, the docs state: 1) An NSXMLParser notifies its delegate about  
the items (elements, attributes, CDATA blocks, comments, and so on)  
that it encounters as it processes an XML document. It does not itself  
do anything with those parsed items except report them. and 2) in  
setShouldResolveExternalEntities, Indicates whether the receiver  
reports declarations of external entities using the delegate method  
parser:foundExternalEntityDeclarationWithName:publicID:systemID:.


I should be clear, then, that NSXMLParser does *not* resolve external  
entities in any way, only reports them, and explains what you see.



I do get:
- (NSData *)parser:(AQXMLParser *)parser resolveExternalEntityName: 
(NSString *)name systemID:(NSString *)systemID

but I have no idea what to return...
the entities are defined in the DTD...


As the docs say, An NSData object that contains the resolution of the  
given external entity


if I could get the folowing for the entries in the DTD, I would just  
build a table myself
- (void)parser:(AQXMLParser *)parser  
foundInternalEntityDeclarationWithName:(NSString *)name value: 
(NSString *)value;


Still, shouldnt NSXMLParser do entity substitution for me?
somehow... :)



The companion document to NSXMLParser, Event-Driven XML Programming  
Guide for Cocoa, tells you what you need to do to resolve external  
entities.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Keary Suska


On Jun 1, 2009, at 1:43 PM, Dominik Pich wrote:


:) thanks but . it doesnt work for me.
I read all that about NSParser just calling you back. I implemented  
all the delegates BUT
I dont seem to be getting an appropriate callback for the Entities  
in the DTD, although I did set 'shouldResolveExternalEntities = YES'


I get that messages asking me to PROVIDE a substitution for an entity
But I never get the messages FOR the declaration of the entities, so  
I dont know WHAT to return as data.


I hope I explained my issue?

For example:
In the xml I have
nameOfPerson; goes to nameOfCiname; :)

I never get to know about the declares (which are in the DTD. which  
should be loaded. no?)


No. That's the point. NSXMLParser does nothing outside of parsing the  
particular XML. It does not load DTDs, it does not validate, it does  
not resolve any links. It is the responsibility of the delegate to  
handle such things as DTD-related functions. You can use the NSXMLDTD  
class for this.


All external entities must be declared in the core XML. If they  
aren't, your XML is not well-formed.  When the parser finds and  
external entity declaration, the delegate is sent - 
parser:foundExternalEntityDeclarationWithName:publicID:systemID: .  
This just gives you a heads-up that the XML document expects to need  
to resolve that entity. When it finds the entity, you should be sent - 
parser:resolveExternalEntityName:systemID: (if you set the option),  
where you return the declaration as it appears in the DTD (as NSData).


I believe that NSXMLDocument may provide the functionality that you  
want, so you might want to look down that route.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Keary Suska

On Jun 1, 2009, at 4:03 PM, Keary Suska wrote:

All external entities must be declared in the core XML. If they  
aren't, your XML is not well-formed.


Correction, this would not be the case for declarations in a DTD,  
which are part of the external subset, so the first delegate message  
should not be sent. But the problem still stands that the parser won't  
load/parse the DTD, and the delegate will have to handle it.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSToolbar: notification of change?

2009-06-01 Thread Keary Suska

On Jun 1, 2009, at 4:53 PM, David Reitter wrote:

Having subclassed NSToolbar, I am now trying to get a notification  
of changes done by the user using the customization palette.
This works fine for the removal of items (toolbarDidRemoveItem:),  
but I can't see a way to get notified of added/moved items after the  
fact.
The only notification I can get is toolbarWillAddItem:, but that's  
obviously before the addition, which is not very helpful.


I have tried implementing insertItemWithItemIdentifier: and also  
setConfigurationFromDictionary:, but it seems that the palette  
doesn't go through these.


Short of regularly monitoring the tool bar for possible changes, I  
don't know what to do...


There is no built-in way to do what you want that I know of. There may  
be third-party subclasses or substitutes, but none that I recall.


You can know when the customization palette is invoked, so all you  
need to check for is when it is closed and then check for changes. You  
could take a snapshot at -runCustomizationPalette:, then set a timer  
that checks -customizationPaletteIsRunning until it returns NO, at  
which time you check for changes. You are still polling, but at least  
it is relatively lightweight.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Cocoa Bindings and Dependent Keys question

2009-05-31 Thread Keary Suska

On May 30, 2009, at 2:18 PM, Kelvin Chung wrote:

I seem to have a very simple question, but the answer is eluding me  
for some odd reason, but here goes:


Suppose I have two NSArrayControllers, ac1 and ac2.  Suppose now  
that I have a third controller ac3, whose content array is dependent  
on both ac1.selection and ac2.selection (or some keypath therein).   
Since I can't bind ac3 to both ac1 and ac2 at the same time, I have  
a class which has a dependent key.  In particular, suppose I have  
the following:


@interface Foo {
  IBOutlet NSArrayController* ac1;
  IBOutlet NSArrayController* ac2;
}
/* ... */
@end

@implementation Foo
- (id) ac1Selection { return [[ac1 selection] valueForKey:@bar]; }
- (id) ac2Selection { return [[ac2 selection] valueForKey:@baz]; }

+ (NSSet*) keyPathsForValuesAffectingAc3ContentArray {
  return [NSSet setWithObjects:@ac1Selection, @ac2Selection, nil];
}


The +keyPathsForValuesAffectingKey is, at least in theory, correct,  
but it won't work. You will never receive KVO notifications when the  
selection changes. Instead, why not just observe selectedObjects of  
each array controller, and in - 
observeValueForKeyPath:ofObject:change:context: send willchange/ 
didchange for the ac3ContentArray key?



- (NSArray*) ac3ContentArray {
  /* Do stuff using -ac1Selection and -ac2Selection */
}
@end


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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, bindings and multiple view NIB

2009-05-28 Thread Keary Suska

On May 27, 2009, at 10:07 PM, Tomaž Kragelj wrote:

Thanks Keary, this works, however it requires that the same binding  
is repeated in each nib where the same list should be handled (some  
views may only need to show it while others can also modify it). I  
was thinking of creating a master set of controllers in the main  
nib, then bind the slave controllers in particular view nib file  
to the values from the corresponding master controller. Is that  
possible, or is it not how bindings should be used?


It is possible, and is within the domain of issues that bindings help  
solve, but I don't see how it would change having multiple repeated  
bindings. In fact, it adds a useless layer onto the problem.



On 27.5.2009, at 22:43, Keary Suska wrote:


On May 27, 2009, at 12:30 AM, Tomaž Kragelj wrote:


GroupItemsController:
- managed object context -  
Application.delegate.managedObjectContext

- ???
The question marks are what I'm missing - if I don't bind to  
anything, then the array controller will simply show all items for  
all groups, however I want to bind this to the  
GroupItemsController from the MainMenu.nib (it is accessible  
through the Application.delegate, but I don't know how to bind it  
in order to show only the items selected by the group in  
GroupsView.nib...


Have you tried Application.delegate.GroupController.selection.items  
(the last key os whatever relationship you need to use)?





Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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, bindings and multiple view NIB

2009-05-27 Thread Keary Suska

On May 27, 2009, at 12:30 AM, Tomaž Kragelj wrote:


GroupItemsController:
- managed object context - Application.delegate.managedObjectContext
- ???
The question marks are what I'm missing - if I don't bind to  
anything, then the array controller will simply show all items for  
all groups, however I want to bind this to the GroupItemsController  
from the MainMenu.nib (it is accessible through the  
Application.delegate, but I don't know how to bind it in order to  
show only the items selected by the group in GroupsView.nib...


Have you tried Application.delegate.GroupController.selection.items  
(the last key os whatever relationship you need to use)?


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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, bindings and multiple view NIBs

2009-05-26 Thread Keary Suska

On May 26, 2009, at 5:21 AM, Tomaž Kragelj wrote:

I'm (again) banging my head with a single window, multiple views app  
using core data. Each of my view is implemented within it's own NIB  
and handled by a NSViewController subclass. The views share the same  
data from the same MOC. Using the following core data model I cannot  
bind the data as I want:


Group --- Item

My intention is to show the list of items that belong to selected  
group. To do that, I add two NSArrayControllers to MainMenu.nib and  
setup their bindings, then expose the controllers through IBOutlet  
to my app delegate. This works as expected. Then I use a separate  
NIB with the view which handles the list of all groups. It also  
contains it's own NSArrayController instance (dragged from the  
palette) which is bound to the master controller from the app  
delegate. This works, it even supports binding the selection.  
However I'm not able to do the same for the items view (again in  
it's own NIB, handled by it's own NSViewController subclass) - the  
closest solution I came to was that ALL items for ALL groups were  
shown, however adding new ones (saving actually) failed since their  
group relation was not set...


I'm sure I'm missing something, can someone point me to a proper  
direction?


How are you binding the item array controller? It has to be bound to  
the group list array controller or to a property of the app delegate  
that depends on its selection.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSURLConnection set to cache

2009-05-18 Thread Keary Suska

On May 17, 2009, at 9:07 PM, Eric E. Dolecki wrote:

I just want to be sure of something - if I set the images to cache,  
when I
load the same url again, the image is coming from memory - because I  
put in

a progress bar and the images loaded already I thought would have an
instantly populated progress bar, but they still load with progress  
(albeit

quicker).


If you are using the default cache policy, there is no guarantee  
whether the resource is in memory, on disk, or will be reloaded from  
its remote source (although you could make a reasonable assumption on  
the latter). Also, the cache is always validated in these cases, so  
there will always be some latency.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Special requirements for the window param of NSAlert beginSheetModalForWindow?

2009-05-14 Thread Keary Suska

On May 13, 2009, at 9:07 PM, Michael Ash wrote:


3) Use performSelector:withObject:afterDelay: with a 0 delay to run
the code to show the new sheet after the old sheet has truly gone
away. This will result in one sheet being followed by another sheet as
you desire.


I have had success with successive sheet display by calling -orderOut:  
or -close: on the sheet before displaying the next. This is also  
documented as the proper way to display successive sheets.


On May 13, 2009, at 10:27 PM, Sean McBride wrote:


Your advice is good, to be sure, but you are incorrect about the  
above.


In fact, the 'do you want to replace?' question is displayed in a  
sheet



that appears on top of the save panel sheet.



Yes, but the docs are clear that stacked or nested sheets are not  
supported, and violate HIG. It also doesn't work well if you try to  
force it.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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] Binding an NSArrayController with/without NSObjectController

2009-05-14 Thread Keary Suska

On May 14, 2009, at 5:51 AM, malte.phil...@mac.com wrote:


Now here is what has me utterly confused and my actual question:

In his tutorial Scott is setting up an NSObjectController (named  
ControllerAlias there) and binds that to the MyController  
instance with the explanation:
quoteThis little green box is your bridge between the code in  
MyController.m and the bindings system./quote
The two NSArrayControllers afterwards are bound to that  
'ControllerAlias' NSObjectController.


Aaron in his book has me creating an NSArrayController and bind that  
directly to the instance with the array to be controlled.  
Essentially skipping the NSObjectController entirely. When I just  
thought it was my bridge to the bindings system?


I would really like to understand the difference in approach between  
these two methods and also if there are any implications by using or  
skipping an NSObjectController in between. Would anyone find the  
time and inclination to explain this to me, please?


Well, these two examples do not solve the same problem, so compare/ 
contrast would not be useful. You need to understand the Model-View- 
Controller (MVC) pattern as it is used in Cocoa. You will find this  
the docs (just search for cocoa patterns and I bet you'll find it  
easily). NSController and its subclasses (which include  
NSObjectController and NSArrayController) were designed  to be the C  
in this pattern specifically for bindings. Have you read Cocoa  
Bindings Programming Topics?


Additional info I would add: the important difference between the two  
examples is that Scott's  uses a tiered approach (common for master- 
detail interfaces, for instance, in their simplest form), where one  
controller provides the content for another controller, while Aaron's  
is the more straightforward single-controller approach (although  
iterate, these aren't approaches to the same problem, but approaches  
to different problems). Note also the purpose of NSObjectController vs  
NSArrayController. As the name implies, the former is for binding to a  
single object, while the latter is for binding to an array of objects.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Hide/Show Password

2009-05-14 Thread Keary Suska

On May 14, 2009, at 9:40 AM, Patrick Neave wrote:



I would like to add a little button next to my apps password field  
to hide/show the password. I have searched this list but although it  
has bee mentioned I can find no example of doing this.  
NSSecureTextField seems to be the way to go but I am not having any  
luck.


A tabless/borderless NSTabView?

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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] Binding an NSArrayController with/without NSObjectController

2009-05-14 Thread Keary Suska

On May 14, 2009, at 11:07 AM, malte.phil...@mac.com wrote:


To possibly refine my initial question a bit better though:
In Scott's example I can *remove* the NSObjectController and bind  
the NSArrayController (he's binding to that NSObjectController)  
*directly* to the MyController instance in IB. And from my  
testing: it's still working exactly the same. So I'm still not sure  
why the NSObjectController is placed in between there. What is its  
purpose?


Allow me the little sketch to illustrate my point:

Scott's tutorial) ControllerInstance --- NSObjectController ---  
NSArrayController --- NSArrayController
Alternative) ControllerInstance --- NSArrayController ---  
NSArrayController


What's that NSObjectController in Scott's example for and what is  
it doing that will not happen in the Alternative binding approach?


I haven't reviewed both examples in detail, but the most likely answer  
is no difference at all. You should be able to--adjusting the  
bindings appropriately in each case--remove the NSObjectController  
from the first example and insert one into the second example, without  
any change in behavior. I have seen a number of examples from Apple  
that use NSObjectControllers in this way, so it may a situation of  
convention, but also refer to Quincy's response.


I would add that an otherwise useless NSObjectController is  
particularly useful in cases where the File's Owner maintains the  
model data. Binding to File's Owner may create retain cycles, so in  
these cases I have the owner offload the data-binding to an object  
controller. I also find them useful in Interface Builder as the app  
will maintain a list of keys and auto-suggest keys when specifying  
bindings. I wouldn't recommend using the class for just this purpose,  
but NSObjectController does have its uses.


Best.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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 delegate methods in NSTextView subclass.

2009-05-06 Thread Keary Suska

On May 6, 2009, at 3:35 AM, Тимофей Даньшин wrote:

I have subclassed NSTextView and I am using that subclass as a field  
editor for an NSTextField. On certain events in the field editor, i  
need to take certain actions again in the field editor, and as of  
now i have to use delegate methods in the TextField's delegate to  
call methods in the TextView, even though the messages that call  
those delegate methods, originate in the TextView.


Is there a way to receive the notifications on those events  
(triggering the delegate methods) in the NSTextView subclass?


The one I am particularly interested in is -controlTextDidChange;


Any delegate method that takes an NSNotification as its sole argument  
is just a notification. Check the documentation for the notification  
name and simply observe for the notification.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSXMLParser frees itself on error?

2009-05-04 Thread Keary Suska

On May 1, 2009, at 12:59 AM, Mike Manzano wrote:

I have an NSXMLParser doing parsing the contents of a URL. It is  
allocated like this:


_showsParser = [[NSXMLParser alloc] initWithContentsOfURL:url];

Given a good URL to a parsable XML document, its  
parserDidEndDocument: method calls this method:


- (void) cleanupShowParsing {
[_buildingShows removeAllObjects];
[_showsParser abortParsing];
[_showsParser release];
_showsParser = nil;
_currentlyBuildingShows = NO;
}

Note that the parser is aborted and released in here. This seems to  
work just fine, multiple times, with no problems. However, if I give  
it a URL to non-XML data (should be a 404 page somewhere), it calls  
parser:parseErrorOccurred: as expected. This method also calls - 
cleanupShowParsing. However, when it is called from here, the  
program eventually terminates with:


2009-04-30 23:53:52.573 Revision3[49280:20b] PARSE ERROR: Error  
Domain=NSXMLParserErrorDomain Code=5 Operation could not be  
completed. (NSXMLParserErrorDomain error 5.)
objc[49280]: FREED(id): message shouldContinueAfterFatalError sent  
to freed object=0xf305a0


I have verified that 0xf305a0 is indeed _showsParser. Further, I've  
verified that if I don't release _showsParser in - 
cleanupShowParsing, no error occurs given a non-XML file.


My question is it the case that NSXMLParser frees itself if it  
encounters an error, but does NOT free itself on a successful parse  
of a document?


No Cocoa object (or Objective-C object, for that matter) instance will  
release itself to the point of deallocation (except in certain  
circumstances of a failed -init). To do so would violate memory  
management and object ownership. Something to keep in mind.


If I may propose a rule: never deallocate an object from one of its  
delegate method calls unless it is documented as specifically  
allowable. You don't know whether the object is complete and won't  
call any of its own methods right after the delegate call. So, don't  
call -cleanupShowParsing in -parser:parseErrorOccurred:, call it only  
from parserDidEndDocument:.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Crashing resetting or releasing an NSManagedObjectContext

2009-05-04 Thread Keary Suska

On May 4, 2009, at 11:59 AM, Alexander Spohr wrote:


You are still having the same error.


Although the advice is sound, the premise is false.

All your objects in the relationships are fetched. Therefore they  
are owned by the NSManagedObjectContext. You kill the  
NSManagedObjectContext by releasing it. After that point you are not  
allowed to touch any of its fetched objects. But you hand them out  
inside the NSDictionary.


The code provided doesn't, in fact, touch the MO after releasing the  
MOC.


Pleas reconsider my first tip and let the calling method create the  
NSManagedObjectContext. Use that to fetch all your objects, process  
them and _then_ kill your NSManagedObjectContext.


An NSManagedObject can not live without its NSManagedObjectContext.  
The NSManagedObjectContext ist the bucket that holds it. You can not  
take it out and throw the bucket away. Will not work.


A good practice, and something the OP is actually doing. As long as  
each property is being copied as the OP indicated, the dictionary  
*only* contains copies of managed object properties, which are  
therefore owned by the caller and *not* by the MO or MOC. So,  
releasing the context should not make any difference, as it is  
released after the MO is processed (by coping its properties) as you  
recommend.



Am 01.05.2009 um 10:24 schrieb Daniel Kennett:

NSManagedObjectContext *context = [[NSManagedObjectContext alloc]  
init];


Pet *pet = [KNClarusQuickDocumentParser petAtURL:url  
inContext:context];


NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

[dict setValue:[[[pet valueForKey:@name] copy] autorelease]  
forKey:@name];
[dict setValue:[[[pet valueForKey:@birthday] copy] autorelease]  
forKey:@birthday];

// More copying of strings and dates
[..]
[dict setValue:[[[pet valueForKey:@pertinentActions] copy]  
autorelease] forKey:@pertinentActions]; // --- Here


[context release];


^ this release kills all fetched objects.


Very true.


return [dict autorelease];


^ this dict contains dead objects.


Probably false, unless there is missing code that violates the rule.  
In any case, this issue is likely irrelevant based on when the crash  
occurs and for what object(s).


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Crashing resetting or releasing an NSManagedObjectContext

2009-05-04 Thread Keary Suska
 it all up.  
I use this code for my Quicklook plugin, and in parts of my app  
for previewing documents in a more advanced manner than  
Quicklook provides.


This is how I set up my ManagedObjectContext:

+(Pet *)petAtURL:(NSURL *)url {

	NSManagedObjectModel *managedObjectModel = 	 
[KNClarusQuickDocumentParser managedObjectModel];
	NSPersistentStoreCoordinator *coordinator =  
[[[NSPersistentStoreCoordinator alloc]  
initWithManagedObjectModel:managedObjectModel] autorelease];


[coordinator addPersistentStoreWithType:NSSQLiteStoreType
  configuration:nil
URL:url

options:nil
 
error:error];

	NSManagedObjectContext *moc = [[NSManagedObjectContext alloc]  
init];
   // ^ Not Autoreleasing here. It's the responsibility  of the  
caller to release the MOC. Autoreleasing causes crashes.


[moc setPersistentStoreCoordinator:coordinator];
[[moc undoManager] disableUndoRegistration];

NSError *fetchError = nil;
NSArray *fetchResults;
	NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init]  
autorelease];


	NSEntityDescription *entity = [NSEntityDescription  
entityForName:@Pet


  inManagedObjectContext:moc];
[fetchRequest setEntity:entity];
	fetchResults = [moc executeFetchRequest:fetchRequest  
error:fetchError];


if ((fetchResults != nil)  ([fetchResults count] == 1)   
(fetchError == nil))

{

NSManagedObject *pet = [[fetchResults objectAtIndex:0] retain];
return [pet autorelease];
}

return nil;

}


And this is how I get the data out and release it:

Pet *pet = [KNClarusQuickDocumentParser petAtURL:url];

// Copy out some data.

NSManagedObjectContext *context = [pet managedObjectContext];

if (context) {

[context reset]; // This call results in EXC_BAD_ACCESS
[context setPersistentStoreCoordinator:nil];
[context release];

}

return [dict autorelease];

 End code 

Different combinations of trying to do this right result in  
crashes at different points. Leaving out [context reset] and  
just releasing it obviously gives EXC_BAD_ACCESS again.  
Autoreleasing the MOC in +petAtURL: causes crashes when the  
autorelease pool pops. The only way I can get it to not crash is  
to -init the MOC and never release or autorelease it, but that's  
causing memory leaks!


Is there a good example anywhere of how to set up and tear down  
a Core Data document correctly?





Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Crashing resetting or releasing an NSManagedObjectContext

2009-04-30 Thread Keary Suska
 in any reply you send.



___

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/atze%40freeport.de

This email sent to a...@freeport.de





___

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/cocoa-dev%40esoteritech.com

This email sent to cocoa-...@esoteritech.com




Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Crashing resetting or releasing an NSManagedObjectContext

2009-04-29 Thread Keary Suska

On Apr 29, 2009, at 2:59 AM, Daniel Kennett wrote:

Different combinations of trying to do this right result in crashes  
at different points. Leaving out [context reset] and just releasing  
it obviously gives EXC_BAD_ACCESS again. Autoreleasing the MOC in  
+petAtURL: causes crashes when the autorelease pool pops. The only  
way I can get it to not crash is to -init the MOC and never release  
or autorelease it, but that's causing memory leaks!


The most common cause if this error is an over-release. Turn on  
zombies and see who (if any) is being over-released. The culprit could  
be in your copy data code, that you don't provide. There doesn't  
seem to be anything obviously wrong (other than explained below), that  
I can see.


Is there a good example anywhere of how to set up and tear down a  
Core Data document correctly?


I can say that the design you present is flawed according to OOP  
rules, specifically how you release the managed object context. An  
object should never release an object it doesn't own or has retained.  
I understand why you are doing this--I am just saying it is a flawed  
approach.


I don't know what the KNClarusQuickDocumentParser class does in its  
entirety, but it may call for a singleton pattern or at least a shared  
object pattern (not a proper pattern name AFAIK, just mentioning the  
technique, for instance, [NSNotificationCenter defaultCenter]).


Tear down, in your case, should be as simple as releasing the MOC. The  
other calls (-reset etc) are unnecessary.


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Group Identity Programming

2009-04-29 Thread Keary Suska

On Apr 29, 2009, at 7:36 AM, Jessica Billings wrote:


The third thing I tried is getting the gid using:
gid_t curGroupID = getgid(); OR
int curGroupID = getgid();
CBGroupIdentity *groupIdentity = [CBGroupIdentity
groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority

defaultIdentityAuthority]];



When I try to show the gid using NSLog, it hangs the program. When I

show
the groupIdentity object, it returns (null).


The above is better. What does the debugger show for curGroupID?  
There

is no reason to hang on NSLog if for curGroupID, as it is really juts
an unsigned int. What is the NSLog code you are using?


Thank you for your help!

The reason NSLog was hanging is that I was using the wrong  
formatting token.

When I use:

NSLog(@current group id: %i, curGroupID);

I get current group id: 1612776775, which I'm assuming is right.  
However,

I am still getting Current group info: (null) when I do:


That is certainly an odd GID, but I suppose it could be. Leopard  
changed everything again, so who knows. Anyway, remember that there is  
no correspondence between the Unix user/group management and the Mac  
OS X system user management. It is possible that the Unix-based means  
of acquiring UIDs and GIDs doesn't work with the Mac's way of doing  
things.


Check your values against what you expect them to be. To get the UID  
and GID for a user, right-click on the user in the system accounts  
pane (system prefs), choosing advanced options. I would also check  
the getuid() call and see if it returns the expected UID. This will  
tell you whether the C calls know about Mac user handling.



CBGroupIdentity *groupIdentity = [CBGroupIdentity
groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority
defaultIdentityAuthority]];
NSLog(@Current group info: %@, groupIdenditity);

Unfortunately, I don't know if solving this problem will solve my  
ultimate
problem (although I'm sure it will help!). My ultimate problem is  
that I
have a number of group identities chosen by the identity picker. I  
need to
look at their member lists and see if the logged-in user is in any  
of those
lists. What I can't figure out is how to get access to the member  
lists of
the groups that I get using the identity picker. I think this has to  
do with
the fact that the identity picker returns CBIdentity objects, but  
how would
one make a CBGroupIdentity object using the information from the  
CBIdentity
object for a particular group identity? The only way I can see to  
make a
CBGroupIdentity object is using the above code, but as the  
documentation


If the getgid/getuid functions don't work, I don't know what to tell  
you. You could try digging into the new user management system (man  
dscl), or NSTask to the id utility (man id).


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Group Identity Programming

2009-04-28 Thread Keary Suska

On Apr 28, 2009, at 8:58 AM, Jessica Billings wrote:

I am trying to write a program that, among other things, generates a  
list of
user and group identities using the identity picker and then checks  
to see
if the logged-on user matches any user identity or is a member of  
any group.
I can do the first task, but I am having trouble with the group  
identity

part.

My main issue, I believe, is that I cannot get to the group-specific
attributes (gid and members). I have tried the function
identityWithName:authority: two different ways:

CBGroupIdentity *groupID = [CBGroupIdentity identityWithName:[tmpArray
objectAtIndex:i] authority:[CBIdentityAuthority  
defaultIdentityAuthority]];

CBGroupIdentity *groupID = [CBIdentity identityWithName:[tmpArray
objectAtIndex:i] authority:[CBIdentityAuthority  
defaultIdentityAuthority]];


Why do think this would work at all? It is not consistent with the  
documentation. -identityWithName:authority: returns a CBIdentity  
object, not a CBGroupIdentity object. So of course it will not respond  
to CBGroupIdentity instance methods.


The tmpArray objectAtIndex:i is an NSString representation of the  
group's

name, but I have also tried it with the UUID.

This gives me the warning initilization from distinct Objective-C  
type.
When I try to call members or posixGID on either of these, the  
program

hangs.


This should have been the first clue that you're doing something wrong.

Also, I have tried to just circumvent creating a group identity and  
get to

the heart of the matter by doing the following, using a test group I
generated myself on the local machine (the other groups were made by  
someone

else and are not local groups):
NSString *user = NSUserName();
CBIdentity *localIdentity = [CBIdentity identityWithName:user
authority:[CBIdentityAuthority defaultIdentityAuthority]];
[localIdentity isMemberOfGroup:[CBGroupIdentity  
identityWithName:@test_group

authority:[CBIdentityAuthority localIdentityAuthority]]];



Except that you aren't circumventing anything, you are juts doing the  
same wrong thing: [CBGroupIdentity  
identityWithName:@test_groupauthority:[CBIdentityAuthority  
localIdentityAuthority]]. You cannot get a group identity this way.



The third thing I tried is getting the gid using:
gid_t curGroupID = getgid(); OR
int curGroupID = getgid();
CBGroupIdentity *groupIdentity = [CBGroupIdentity
groupIdentityWithPosixGID:curGroupID authority:[CBIdentityAuthority
defaultIdentityAuthority]];

When I try to show the gid using NSLog, it hangs the program. When I  
show

the groupIdentity object, it returns (null).



The above is better. What does the debugger show for curGroupID? There  
is no reason to hang on NSLog if for curGroupID, as it is really juts  
an unsigned int. What is the NSLog code you are using?


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSArrayController: Objects with empty strings

2009-04-28 Thread Keary Suska

On Apr 28, 2009, at 8:59 AM, MyApps wrote:

First off, a suggestion: please don't delimit code sections like you  
do. In fact, you don't need any delimiters other than whitespace (as  
you can see with the edited text below). And you can see, it is just  
as readable, and, IMHO, it is actually *more* readable.


Anyway, on the the question...


If I do this:

NSMutableDictionary *theDicRow = [NSMutableDictionary  
dictionaryWithObjectsAndKeys:

@Text A, @colA,
@, @colB,
nil ];

The result is:

[2355:10b] (
   {
   colA = Text A;
   }
)

But I wanna have the empty string back. So it seems, that the empty  
string is converted to nill and the controller is killing them out.
How can I change this reaction with empty strings? I need this @  
Strings.


I am not surprised to see this behavior, for various reasons. The  
short answer is no, you can't have an empty string for a key in  
conjunction with an NSArrayController. What would be the key path for  
an empty string?


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSArrayController: Objects with empty strings

2009-04-28 Thread Keary Suska

On Apr 28, 2009, at 1:39 PM, Alexander Spohr wrote:


Am 28.04.2009 um 21:22 schrieb Keary Suska:

NSMutableDictionary *theDicRow = [NSMutableDictionary  
dictionaryWithObjectsAndKeys:

@Text A, @colA,
@, @colB,
nil ];
I am not surprised to see this behavior, for various reasons. The  
short answer is no, you can't have an empty string for a key in  
conjunction with an NSArrayController. What would be the key path  
for an empty string?


As a note: the code sets the value to the empty string. The key is  
colB.



It pays to pay attention. Sorry for that.

Anyway, I am still not entirely surprised, as the GUI doesn't  
distinguish between empty and nil values. At least as far as an  
NSTextField/Cell is concerned. I would be curious whether there is a  
binding to the value, and if unbound, the behavior remains.


I have had to deal with this situation particularly as it related to  
RDBMS's, which *do* distinguish between NULL and and empty, and it's  
an important distinction. In cases where you know you will need to  
handle an empty value and you want to make sure it will *never* be  
nil, you can use a transformer.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSTextField notification if selection changed

2009-04-27 Thread Keary Suska


On Apr 27, 2009, at 11:48 AM, David Alter wrote:

How can I get notification if the Selection changed in a  
NSTextField. This

works with a NSTextView by setting up the delegate -
(void)textViewDidChangeSelection:(NSNotification *)aNotification

A NSTextField uses a NSTextView for its editing. And the NSTextField  
is the
delegate to the NSTextView. If I need to get the selection changed  
should I

be subclassing NSTextField and placing the textViewDidChangeSelection
delegate method in there. Or is there a simpler solution to this.



Once you get a reference to the field editor, you can observe its  
NSTextViewDidChangeSelectionNotification.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: problems with live resize of NSTextView

2009-04-25 Thread Keary Suska


On Apr 24, 2009, at 3:06 PM, Stuart Malin wrote:

I have an NSTextView in a custom view, it is set to resize with the  
containing view only in the horizontal dimension. When I resize the  
window, the text view does resize, and it does re-layout its content  
to fit, both on expanding and shrinking. However, the text view not  
only changes its frame size height, but repositions itself (changing  
the y value of its frame's origin). Why does it do this?


You need to read the Cocoa Drawing Guide and View Programming Guide  
for Cocoa. The answer is explicit: the 0,0 coordinate of the Cocoa  
drawing system is the bottom left.


More important to me: where is the best place for me to detect this  
change because I want to change the parent view's height to  
accommodate any increase in height in the text view.


One possible approach is to observe NSViewFrameDidChangeNotification  
coming from the view. See the NSView documentation for how to use it.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: undoMenuTitleForUndoActionName

2009-04-25 Thread Keary Suska

On Apr 25, 2009, at 10:49 AM, norio ota wrote:


I need to localize the undo menu title.
I made the subclass of NSUndoManager and overrode two methods:
undoMenuTitleForUndoActionName and redoMenuTitleForUndoActionName.

Bun they don't get called.

Would you tell me who calls the functions and , if possible,
how I should do to localize the titles instead of general ones?


The issue, in your particular case, is probably more of an issue of  
how to get various parts of Cocoa to use your NSUndoManager subclass.  
Is there a reason that -setActionName: won't work? I imagine it could  
be rather awkward grammar in some languages, but it would be a lot  
easier.


Otherwise, IIRC, all controls will use the Window's undo manager, so  
if you have the window delegate implement - 
windowWillReturnUndoManager:, you can force the use of your subclass.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: problems with live resize of NSTextView

2009-04-25 Thread Keary Suska

On Apr 25, 2009, at 12:05 PM, Stuart Malin wrote:


On Apr 25, 2009, at 5:08 AM, Keary Suska wrote:


On Apr 24, 2009, at 3:06 PM, Stuart Malin wrote:

I have an NSTextView in a custom view, it is set to resize with  
the containing view only in the horizontal dimension. When I  
resize the window, the text view does resize, and it does re- 
layout its content to fit, both on expanding and shrinking.  
However, the text view not only changes its frame size height, but  
repositions itself (changing the y value of its frame's origin).  
Why does it do this?


You need to read the Cocoa Drawing Guide and View Programming  
Guide for Cocoa. The answer is explicit: the 0,0 coordinate of the  
Cocoa drawing system is the bottom left.


Ah, I wasn't clear, because of course the origin would move down as  
the text expands downward. What I am seeing though is that the  
origin moves down more than the increase in height, so the text view  
isn't just expanding, but expanding and moving downward (that is,  
even its top moves down).


Is the NSTextView anchored to both the top and bottom edges? If not,  
you may get this behavior.


More important to me: where is the best place for me to detect  
this change because I want to change the parent view's height to  
accommodate any increase in height in the text view.


One possible approach is to observe  
NSViewFrameDidChangeNotification coming from the view. See the  
NSView documentation for how to use it.


Thanks for reminding me of this. I need to see whether the  
notification occurs before a redraw cycle. If so, I can propagate  
relevant resizes up the chain of parent views.


It would probably be better to put the textview in a scrollview (or  
make the textview's parent an NSScrollView subclass). You wouldn't,  
for instance, want the window to grow larger than the screen size.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings making NSNumberFormatter strange

2009-04-23 Thread Keary Suska

On Apr 22, 2009, at 6:24 PM, Ulai Beekam wrote:

So I really must make a custom field editor to accomplish on-the-fly  
validation (i.e. disallowing on-the-fly invalid characters)?


It is not your only choice, but it is probably the best choice.  
Another poster suggested using isPartialStrignValid of the formatter,  
but I have tried this in the past and run into undo issues,  
particularly when using it to filter input. The problem is that undo  
registration happens before the validation call, and somehow the undo  
typing feature remembers the string, so when you change the string in  
the validator method, and then undo, you can get add results and out- 
of-bounds exceptions. Since then I haven't looked into why this  
happens and how to get around it, if at all possible.


I suppose I could do a custom field editor and override keyDown:,  
checking for characters in [NSCharacterSet  
decimalDigitCharacterSet], etc. In fact, having made some custom  
field editors in the past I know I would be able to do this.  
However, I consider this to be a somewhat lame hack :( I therefore  
want to make sure with you guys that there is no easier solution to  
this, e.g. to somehow use the number formatter as a basis for  
automatic on-the-fly validation.


I think that is exactly what you want to do, and doesn't sound like a  
lame hack to me. But someone else may have better advice.


There is a solution that seems to me a bit of a hack, but works in a  
pinch: implement the -controlTextDidChange: delegate method, and in  
that method check for invalid characters, and if found, beep, clean  
them out, then set the fields value to the cleaned string.


The whole thing just seems strange to me. Because when the text  
field is not bound, on-the-fly validation seems to work just fine!  
But this great feature goes away as soon as the text field is bound.  
That is, as soon as the text field is bound, the validation stops  
being on-the-fly and goes elsewhere instead. Is there no way having  
the validation ALSO as an on-the-fly thing? H.


I am not sure what you are describing here. Did you check  
continuously updates value in the binding?


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings making NSNumberFormatter strange

2009-04-23 Thread Keary Suska


On Apr 23, 2009, at 2:25 PM, Lee Ann Rucker wrote:


It is not your only choice, but it is probably the best choice.
Another poster suggested using isPartialStrignValid of the formatter,
but I have tried this in the past and run into undo issues,
particularly when using it to filter input. The problem is that  
undo
registration happens before the validation call, and somehow the  
undo
typing feature remembers the string, so when you change the string  
in

the validator method, and then undo, you can get add results and out-
of-bounds exceptions. Since then I haven't looked into why this
happens and how to get around it, if at all possible.



There's no workaround. I tried writing my own Undo handler, but as  
you've discovered the changes happen before there's a chance to  
handle them.


Formatters work, and bindings work, but the combination doesn't. The  
only solution I've found is to use a formatter without bindings,  
since having the formatter is more important than having bindings,  
useful as they may be.


Just to be clear, are you saying that you can do field filtering with  
a formatter, with appropriate undo support, without bindings, or are  
you making a general remark about difficulties when using bindings  
with formatters?


Thx,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings making NSNumberFormatter strange

2009-04-22 Thread Keary Suska

On Apr 22, 2009, at 3:57 PM, Ulai Beekam wrote:

To elaborate, when not using bindings, the default behavior of text  
fields with a number formatter is that when a user tries to enter  
abc in it, the text field refuses to lose focus and makes a  
beeping sounds.


However, when the text field's value binding has been set, a sheet  
is shown, which I think is a bad user experience.


That's because no one is handling the error. Bindings gives you some  
automatic error support. Otherwise you have to handle the error  
yourself. This is well documented. If you don't like the experience,  
then change it.


In fact it would be even better to just disallow entering of invalid  
characters in the first place. But such a method would have to work  
even if the text field's value binding is set.


I agree with you that having some sort of built-in support for entry  
filters would be great (I would add length limiters as well). I think  
we had this back in the Mac toolbox days, if I am remembering properly.


Anyway, there are two different issue to consider. One is validation,  
and the other is custom editor behavior. They are really two different  
problems, although there is overlap.


My problem is that when I type some invalid stuff in the text  
field, such as some letters abc, I don't get a beep (which is the  
normal behaviour and the one I want), but I get some sheet popping  
up saying Formatting Error. I don't want this sheet. I want the  
beep like usual. How can I get rid of this sheet behaviour that the  
bindings is causing? And why is it even causing it?




Because that's how formatters work. Getting rid of the sheet is  
nontrivial if you allow the formatter or bindings to do validation.  
Also, your formatter (or your model object, using key-value  
validation) can provide a more sensible error message if you choose.


Second question: How can I make my text field just disallow  
entering of invalid characters in the first place (and producing  
beep when it is tried)? I want, as you probably guessed, a method  
that is compatible with bindings.



You can use the formatter to check data on the fly, but you have to  
control the undo manager or you will get exceptions on undo. You can  
also have a custom field editor, for finer grained control. Both of  
these have decent documentation. I would be surprised if no-one has a  
framework that offers some of this behavior.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Select Object in NSDictionaryController

2009-04-20 Thread Keary Suska


On Apr 19, 2009, at 1:29 AM, Gerriet M. Denkmann wrote:

I have a table with two columns, labeled Key and Value bound to  
myDictionaryController.key and myDictionaryController.value.


Now I want to select a row programmatically (e.g.  
[ myDictionaryController selectRowWIthKey: @someKey ]; ).

But such a method I cannot find.


There is no such facility, unfortunately. It would be nice. Why not  
file an enhancement request?


And trying to use the inherited selectObjects: does not work  
(nothing happens, not even an error message).


Well, -selectObjects: can't be used to change a controller's  
selection, so no wonder you aren't getting anywhere.



So: how can I select a row in my table?



Normally, -setSelectedObjects:, -setSelectionIndex:, or - 
setSelectionIndexes:. If they don't work, and you want help with that,  
then be specific about what precisely you tried (i.e. show code!). It  
also helps to mention what you expect to happen, and what is actually  
happening differently than your expectation.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Select Object in NSDictionaryController

2009-04-20 Thread Keary Suska

On Apr 20, 2009, at 11:12 AM, Gerriet M. Denkmann wrote:

NSArray *defs = ...some array... (which is bound to content of  
definitionsArrayController)

NSUInteger defIndex = 0;
for( NSDictionary *aDef in defs )
{
for( NSString *defKey in aDef )
{
NSString *value = [ aDef objectForKey: defKey ];
BOOL ok = ... some test with value  
if ( !ok )  //  select the bad thing
{
			[ definitionsArrayController setSelectionIndex: defIndex ];	//	 
this works fine
			//	now the table shows aDef and the first row in the table is  
selected
			[ myDictionaryController setSelectedObjects: [ NSArray  
arrayWithObject:


This doesn't work because the selected object(s) need to be the actual  
objects managed by the controller.



This code works (but seems incredibly complicated and inefficient):

NSArray *arrangedObjects = [ dictController arrangedObjects ];
id theThing = nil;
for( id something in arrangedObjects )
{
NSString *key = [ something key ];
if ( [ key isEqualToString: defKey ] )
{
theThing = something;
break;
};  
};

if ( theThing == nil )  //  error
{
NSLog(@%s Error not found,__FUNCTION__);
}
else
{
 [ dictController setSelectedObjects: [ NSArray arrayWithObject:  
theThing ] ];

};



This, or something similar, is probably your best bet. Also, chances  
are any other apparently shorter solution would really just do the  
same thing.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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 Fetches + Transient Properties + NSPredicateEditor = Sadness

2009-04-17 Thread Keary Suska


On Apr 16, 2009, at 9:01 PM, Jerry Krinock wrote:

The fact that Core Data cannot fetch using a predicate based on  
transient properties [1] seems to greatly limit the utility of the  
NSPredicateEditor view, and makes me very sad.


For example, say that my objects are student test results with a  
'score' attribute and two dozen other properties.  I could give the  
user an NSPredicateEditor and let them have oodles of fun  
constructing complex predicates.


But what if I need the user to be able to set a predicate with a  
left-side-expression of letter grade and a right-side-expression  
popup menu showing 'A' - 'F'.  If I could fetch based on a transient  
'letterGrade' attribute, I could implement some custom accessors  
which would calculate 'letterGrade' from 'score' as needed, the  
predicate emitted from the NSPredicateEditor would just work, and  
life would be sweet.


But since I can't use transient properties in my predicate,  
providing a popup like that in NSPredicateEditor seems to mean that  
I'm going to have to somehow deconstruct the compound predicate  
which Apple put so many man-years of engineering into, have Core  
Data do sub-fetches, then do my own filtering and put the results  
back together.  I fear that writing bug-free code to handle the  
general compound predicate would be very time-consuming, and also it  
would be MVC hell with my NSPredicateEditor subclass (view) code  
wanting to have model logic such as if score  93, letterGrade =  
'A'.



I am not really up to speed on NSPredicateEditor, but could you use - 
ruleEditor:predicatePartsForCriterion:withDisplayValue:inRow: to  
convert the display case of grade = A-F to a predicate that is  
actually grade = = score range? I imagine you would need to  
construct a compound predicate with subpredicates (sub-rows). Either  
that or use the BETWEEN operator.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: C: treated as a path component

2009-04-15 Thread Keary Suska

On Apr 14, 2009, at 5:57 PM, Dragan Milić wrote:


Hell all,

Let's suppose I've got NSString @C:omponent , which represents the  
name of a file. Is there a way to instruct NSString class not to  
treat a leading single letter followed by a column as a path  
separator? Namely, I need this one treated as only one path  
component @C:omponent, but NSString sees two, @C: and  
omponent. So, if I ask for the last path component, I get  
@omponent instead of the whole string @C:omponent.


I don't believe so, as I believe colon-separators are are deeply  
ingrained into the file system. You will probably need to parse the  
path names yourself. Look at one of the regex libraries for easy  
parsing.


Carbon is not dead, it just smells funny.

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Programatically creating NSMenu?

2009-04-08 Thread Keary Suska


On Apr 8, 2009, at 7:13 AM, Daqi Pei wrote:

I've been trying to create a Cocoa GUI application without IB.  
Everything

works fine except for the NSMenu.
After digging over the internet I found a solution from '
http://lapcatsoftware.com/blog/2007/06', by using some undocumented  
methods

and member variables.

I succeeded in creating the application, and what I found  
interesting is, it

seems that if I run the application from Terminal, no menu
would be shown (the Windows still work fine). The only way to have  
the menus
working properly is to create an Application.app directory  
structure, and
run from Finder. Apps with static Nibs work fine both running from  
Terminal

and Finder.

Again I'm doing this only to understand how the system works. Did I  
miss

something or it's just the way the framework was designed?



http://lapcatsoftware.com/blog/2007/05/16/working-without-a-nib-part-1/

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Programatically creating NSMenu?

2009-04-08 Thread Keary Suska

On Apr 8, 2009, at 8:53 AM, DairyKnight wrote:

Sorry but I don't really see the connection between that page and my  
question?


Sorry, probably answers the wrong question. Anyway, what is the  
difference between an apps with an Application.app directory  
structure and apps with static Nibs? If in both cases you have an  
application bundle, you are halfway to your answer.  
NSApplicationMain() requires a bundle. It can find its resources even  
when directly launched via terminal. I expect that using  
NSApplicationMain() without an app bundle is undefined, and hence the  
behavior you are seeing.


On Wed, Apr 8, 2009 at 9:44 PM, Keary Suska cocoa- 
d...@esoteritech.com wrote:


On Apr 8, 2009, at 7:13 AM, Daqi Pei wrote:

I've been trying to create a Cocoa GUI application without IB.  
Everything

works fine except for the NSMenu.
After digging over the internet I found a solution from '
http://lapcatsoftware.com/blog/2007/06', by using some undocumented  
methods

and member variables.

I succeeded in creating the application, and what I found  
interesting is, it

seems that if I run the application from Terminal, no menu
would be shown (the Windows still work fine). The only way to have  
the menus
working properly is to create an Application.app directory  
structure, and
run from Finder. Apps with static Nibs work fine both running from  
Terminal

and Finder.

Again I'm doing this only to understand how the system works. Did I  
miss

something or it's just the way the framework was designed?


http://lapcatsoftware.com/blog/2007/05/16/working-without-a-nib- 
part-1/



Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: SQLite and Unicode

2009-04-07 Thread Keary Suska


On Apr 6, 2009, at 2:31 PM, Тимофей Даньшин wrote:

When I insert non-latin strings into my SQLite3 database, they turn  
into some weird sets of characters (as I select those strings later  
in Terminal), and the fields, which contain those strings, become  
unusable by my application.


I googled for it for quite a bit, but everywhere it says that SQLite  
3 supports utf8, so there is no advice on what should be done in  
such situations.


What can I do about it?


Are you properly encoding your C strings with -cStringUsingEncoding:?  
If so, when you query the column (and properly translate the C string  
to NSString using -stringWithCString:encoding:), are the characters  
still mangled?


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Auto Resize Views Issues

2009-04-07 Thread Keary Suska

On Apr 7, 2009, at 8:22 AM, I. Savant wrote:

On Tue, Apr 7, 2009 at 9:56 AM, Rama Krishna vrk.li...@gmail.com  
wrote:


I get the animation all right. However all the sub view sizing and  
layout is

disturbed. Some views appear above other views and so on.

What is the proper way to animate a view from zero size to the  
desired size?


 I believe this is a known issue with the autoresizing mechanism.
Specifically, autosizing behavior does not work correctly when a view
has been sized to 0,0. I don't believe there is a workaround for
animating the size of your view directly.



I would add to this that I found that if views overlapped when their  
container view was shrunk (to any size that would cause views to  
overlap, not just to 0), when the container view grows the subviews  
would get placed in apparently undefined ways. This may be an  
overlapping views issue.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: SQLite and Unicode

2009-04-07 Thread Keary Suska


On Apr 7, 2009, at 10:39 AM, Тимофей Даньшин wrote:



On Apr 7, 2009, at 8:14 PM, Keary Suska wrote:

Are you properly encoding your C strings with -cStringUsingEncoding:?

Yes, I think so.
At present, I am using the -UTF8String method, but I also tried the - 
cStringUsingEncoding: to no avail.


Here is the line that binds the string to the prepared statement:
	sqlite3_bind_text(sentence_insert_statement, 1, [string  
UTF8String], -1, SQLITE_TRANSIENT);
and I translate it back into NSString by [string  
stringWithUTF8String], although I also tried the -stringWithCString:  
encoding: method. The characters _are_ mangled.
And the funny thing is that i am able to add non-latin strings to it  
by reading sql files from SQLite in Terminal...



How do you define string (i.e. how is its value set)? There can be  
an issue with UTF8 constant strings. Have you called - 
canBeConvertedToEncoding: to make sure string is utf-8 compatible?


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: SQLite and Unicode

2009-04-07 Thread Keary Suska


On Apr 7, 2009, at 12:54 PM, Тимофей Даньшин wrote:


I am deeply and sincerely ashamed of myself.
The point is that i get that input string by splitting the string in  
my textView ([[myTextView textStorage] string]) into sentences.  
During that procedure i check every char if it is a sentence  
terminator (?! or linebreak). And i do that by using the - 
characterAtIndex: method. And the thing is that that method returns  
wrong characters if it deals with unicode ones. Thanks Keary Suska  
for pointing that out to me.


I will now have to find another unicode-safe way to split the  
string into sentences.


Thanks again for all your help.
And if you could give me a hint on how to safely get unicode chars  
at a given position of a string, I'd be even more grateful :)


Apple's String Programming Guide for Cocoa will give you info on how  
to handle unicode strings.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings and MenuItems

2009-04-01 Thread Keary Suska

On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:

I have a menu item that is bound to a target.  The menu is resides  
in has Auto Enables Items checked which means that it should call - 
validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding and  
set the target to one of the objects manually in IB the validation  
method is called as expected.  Has anyone else run into this and if  
so, is there a work around?



IIRC, I had a situation where I discovered that both target  action  
have to be bound (i.e. key-value binding) or target-action fails  
entirely.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings and MenuItems

2009-04-01 Thread Keary Suska


On Apr 1, 2009, at 12:31 PM, Ben Lachman wrote:

I mean a Cocoa bindings kind of binding.  e.g. the target  
binding of the menu item is bound in IB.  The action field of the  
binding is set to print:.  I'm not talking about the traditional  
way of connecting a button/menu item to another object through the  
basic control drag from source to target and select the action  
method and I'm not talking about setting it in code.  I know how to  
do both of those and they work, what I'm going for is a dynamic  
target.



I think I wasn't recalling correctly--my issue had to do with an  
NSButton, and binding didn't work for me. There is no reason to  
suspect that the binding wouldn't work as advertised.


Anyway, I suppose you have verified that the correct object is being  
set when the binding is established (and/or when the bound property  
changes)?


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Delayed Undo Problem

2009-03-30 Thread Keary Suska


On Mar 30, 2009, at 5:55 AM, Richard Somers wrote:

I have a basic core data document based application (Hillegass 3rd  
Edition, Chapter 11, CarLot). With a single primary window every  
thing works. Then a second window is added with a generic master  
detail interface using the core data entity from the Interface  
Builder pallet.


When making a change to the model in the second window, undo/redo in  
the main menu is not available until the primary window is clicked  
and brought to the front.


I need the undo/redo menu to work regardless of which window is  
frontmost. Any thoughts as to how this can be done?



This FAQ might help:

http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdFAQ.html#/ 
/apple_ref/doc/uid/TP40001802-244036


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Porting BASIC text mangling app to Objective-C

2009-03-26 Thread Keary Suska

On Mar 25, 2009, at 12:06 AM, Ricardo Balderas wrote:

I'm starting with a Cocoa Document Based project, but am having  
trouble with Opening and Saving of documents. The stump comments in  
MyDocument.m are beyond me still, and I've tried the Building a  
Text Editor in 15 minutes example, but the opening and saving  
documents part is a bit outdated and gets confusing. Could you help  
me with a simple and well explained sample code of how  to Open and  
Save files? Also, how can I make the app save .txt or .rtf files? I  
managed to make it output . files and read them back, but trying  
to add other file types (taken from the TextEdit source code) led to  
problems reopening a saved file.



A document-based approach is probably not useful for your example. If  
you really want to get into file management in Cocoa, refer to the  
NSFile* classes. At this early stage, I wouldn't bother yet and just  
look at NSString's -initWithContentsOfFile:encoding:error: and - 
writeToFile:atomically:encoding:error: and the NSScanner class.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Overriding -dealloc on any object

2009-03-25 Thread Keary Suska

On Mar 25, 2009, at 7:29 AM, Ryan Joseph wrote:

The question is, will it be safe to override methods like  
initWithObjects: that are owned by Cocoa and created through  
convenience functions? Will those objects be sent -dealloc also?  
Second, given the Objective-C runtime should I replace the  
implementation using class_replaceMethod or do I need to add a new  
method using class_addMethod? I did observe that -dealloc does  
indeed have an implementation so I'm not sure class_addMethod will  
even have any affect, but I'm not sure replace the implementation is  
safe either. Any help is appreciated. Thanks!



I am not entirely certain I am following you but to work with Cocoa  
(in a non-GC environment) you will need to follow (and expect all  
Cocoa objects to follow) the Memory Management Guidelines. This  
document will tell you most, if not all, you need to know about memory  
management in Cocoa.


If you need to essentially override -dealloc that will be inherited by  
all objects, well, that's tricky, and requires some knowledge and use  
if Obj-C runtime functions. Beyond me. But then, do you really need  
that? I don't know what is involved in creating these bridges, but  
it seems saner to me to maintain your own set of manager objects  
that then control native Cocoa objects.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Implementing a many-to-many (reflexive) relationship using bindings and an NSTableView

2009-03-25 Thread Keary Suska

On Mar 25, 2009, at 2:44 PM, Jon C. Munson II wrote:


Do you mean here that you will pop up a window that contains an
NSTableView that will be used to select rows of Entity B? Correct
language is critical. I think most Cocoa developers would assume that
popup means NSpopupButton.



[Jon C. Munson II] Yes, an NSPopupButton is what I meant to imply  
here.


How would you do that? A popup button may only represent a single  
value. If you need to represent multiple values, you will need  
something like mmalc's the checkboxes example or a table view.



You should be able to use bindings for everything you describe except
for setting relationships between existing objects. That will have to
be done in code, AFAIK, but isn't difficult.

[Jon C. Munson II]  OK.  Benjamin Stiglitz responded suggesting I  
take a
look at the ToManyCheckbox example on mmalc's page, so I'll do that  
and see
if that clarifies things.  Also, I noticed in the iClass example  
that code
is used to support the relationship and so on.  Is that the  
recommended

template implementation to support this type of relation?


You might be able to use an array controller whose content is the to- 
many relationship, calling addObject: with the managed object to add  
to the relationship, but otherwise the controller wouldn't interact  
with the UI. At that rate, it is probably better to set the  
relationship in code.


Generally, inserting new objects into a to-many relationship using an  
array controller is a common method.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSLevelIndicator Bindings Crash

2009-03-24 Thread Keary Suska


On Mar 23, 2009, at 2:04 PM, Walker Argendeli wrote:

Yes, you're right, Item is an NSArrayController representing the  
entity Item.  Sorry about that.
ItemsList is an Entity and Array Controller representing an outline  
view of folders.  Each folder can have multiple Items in it.   
Depending on which folder is selected in the ItemsList outline view,  
the right Items will appear in the Table view whose columns are  
bound to properties of the Item array controller.  Depending on  
which item is selected in the Item tableview, the level indicator,  
which is bound to (the array controller) Item.selection.priority


The Item.selection.priority keypath indicates that you are  
referencing the key Item of the array controller (as you describe).  
How is that key defined?


For some reason though, I get the odd behavior that follows:  In the  
Item table view, if I have one item selected, then select a  
different one, that new Item will have the levelindicator defaulted  
back to 1, though it had been set to a different value previously.


Are you saying that the level indicator always shows 1, no matter what  
the bound value is, or that it changes back to the original value  
after you change it?


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSSegmentedControl send action only from the selected segment

2009-03-24 Thread Keary Suska


On Mar 24, 2009, at 3:54 AM, Michele Barboni wrote:



On Mar 19, 2009, at 10:11 AM, Michele Barboni wrote:


Hi,

I've a NSSegmentedControl, 7 segments (labeled with weekdays),  
which has selectedIndex bound through a value transformer (NO  
reverse transformation) to NSDates.

Now, one of my awakeFromNib do this:

[sedutaDays setTarget:self];
[sedutaDays setAction:@selector(setWeekDay:)];
[sedutaDays setContinuous:YES];

setWeekDay: essentially change the day of the NSDate which  
NSSegmentedControl is bound to, by accessing the NSArrayController,  
selectedObjects:, objectAtIndex:0, and so on..


The problem is that my setWeekDay: action is sent only if I click  
the selected segment (set by binding), clicking on any of other 6  
segments results in an attempt to reverse transform the value,  
which obviously fail with [NSCFNumber  
timeIntervalSinceReferenceDate]: unrecognized selector sent to  
instance 0x1019a40 since my value transformer doesn't reverse..


Any idea why it seems that only selected segments has setAction: ?



Passed two last days trying to understand why my NSSegmentedControl  
has this behavior but nothing came out.. I'm very disappointed..


It is not the behavior of the NSSegmentedControl, but bindings that  
you are not understanding. The binding is not trying to reverse  
transform , or you would get a different error message--assuming that  
your transformer is properly implemented, that is.


Refer to:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/MessageFlow.html#/ 
/apple_ref/doc/uid/TP40002149-186285


If your transformer does not support reverse transformations, then  
your setter method must assume that it is receiving a transformed  
value--in this case, an NSNumber. Does it make this assumption?


Note that the segment control would have sent your action method if  
you didn't get the exception first. Selecting the currently selected  
segment works because you are not changing the bound value, which is  
precipitating the exception.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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 path for values in Shared User Defaults?

2009-03-24 Thread Keary Suska


On Mar 23, 2009, at 1:54 PM, Matthias Arndt wrote:

Please help me: What is the key path of a value stored in the shared  
user defaults?


I'm using a sub-classed NSViewController to enhance the print panel  
with an accessory view:



NSBundle *appBundle = [NSBundle bundleForClass:[self class]];
NSViewController *accessoryViewController = [[PrintOptions alloc]  
initWithNibName:@PrintOptions bundle:appBundle];
[[printOperation printPanel]  
addAccessoryController:accessoryViewController];


The view PrintOptions includes three checkboxes, all bind to the  
Shared User Defaults Controller. The printed view uses these values  
to modify its output. Everything works fine except the preview in  
the print panel: It isn't updated when I check / uncheck any of the  
boxes, although the view controller conforms to the  
NSPrintPanelAccessorizing protocol and should use KVO to be  
notified for changes.


I think my keyPathsForValuesAffectingPreview implementation is  
wrong as I don't know how to reference a shared user default:



- (NSSet *)keyPathsForValuesAffectingPreview
{
	return [NSSet setWithObjects: @PrintFastMode, @PrintJumps,  
@PrintGrid, nil];

}


The documentation I found only mentioned an example with document  
margins, but what is the key path for properties bind to the user  
defaults? Sorry, I'm totally lost ...



OTOH, you could have an outlet to the defaults controller, say, named  
defaultsController and use @defaultsController.values.DEFALTSKEY  
to keyPathsForValuesAffectingPreview. I think that is supposed to  
work...


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: How to draw text with expanded inter-character spacing

2009-03-23 Thread Keary Suska


On Mar 23, 2009, at 7:20 AM, Fabry, Geza wrote:

I would like to draw some text into my custom view wider than usual  
but

not by stretching the glyphs using a transformation but by increasing
the spacing between the glyphs (like in Font  Character Spacing 
Spacing  Expanded/Condensed in MS Word). Is there an attribute for an
NSAttributedString like kATSUAfterWithStreamShiftTag was in ATSUI or  
any

other way to do that?


I think what you want is to change the font tracking, but I don't  
think there is a way to do that easily (no public setting for it). You  
could try fiddling with font kerning, but that might  have an  
inconsistent look. There is a font manager property called font  
trait, but I think that requires an actual font variant for  
condensed, expanded, etc. I don't know if it can be faked. You could  
fake it by inserting space characters of determined sizes, or scrap  
the text view do your own thing (which is likely what Word is doing).


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSLevelIndicator Bindings Crash

2009-03-23 Thread Keary Suska


On Mar 23, 2009, at 1:13 PM, Walker Argendeli wrote:

When i do this, however, every time I switch back to another item,  
the level defaults back to 1.  Also, I checked that chapter in  
Hillegass's book, and it had an example where it used  
Car.selection.condition, so it seems that selection is the right  
controller key.  The bindings in general are just really funky.  I  
added a stepper and textbox in addition to the level indicator, and  
bound them to Item.selection.priority, and they too default back to  
1 (the default value) every time I go to another item.  The Item  
array controller's Content Set is bound to ItemsList.selection.Item  
That's the only binding, other than the managed object context.  I  
really can't figure out what's causing this problem, which is  
annoying because I'm trying to focus on fixing this before I  
continue development.


Your descriptions make no sense. When referencing binding key paths,  
make them relative to the controller, and not to the model. I assume  
that when you say Item.arrangedObjects.priority you really mean  
NSARRAYCONTOLLER.arrangedObjects.priority. This is a critical  
distinction, as the two paths are nowhere near the same.


Ok, so you have an entity Item, and you have an NSArrayController  
with Content Set bound to ItemsList.selection.Item. What is ItemsList,  
and why does it exist? What controller is providing content to the  
table view?


Generally the proper approach is: 1. array controller with bound MOC  
that either performs its own fetch or is populated programmatically;  
2. tableview bound (technically, columns are bound) to that array  
controller; 3. detail items (level indicator and stepper) bound to  
arraycontroller.selection.property (where arraycontroller is the  
controller specified in #1).


That should be all there is to it.


On Mar 22, 2009, at 10:05 AM, Richard Somers wrote:


On Mar 21, 2009, at 3:41PM, Walker Argendeli wrote:

I'm using Core Data, and I have an entity; we'll call it Item.   
It has an attribute called priority.  In the xib, I have an  
NSLevelIndicator and NSStepper. I have a NSTableView full of  
Items.  Depending on which item is selected in the table view, I  
want the level indicator and stepper to display the right values,  
and for me to be able to set them to a certain value for each  
item.  There are 2 problems: If I bind the value of either one to  
Item.arrangedObjects.priority, the app throws an exception,  
whereas if I bind to Item.selection.priority, the controls don't  
set each item's priority individually.  What should I bind to?
Secondly, an NSLevelIndicator wants a float for its value, whereas  
an NSStepper wants a double for its value.  Which should I set it  
to in the core data model?


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Is it a Value or an Object ?

2009-03-21 Thread Keary Suska


On Mar 21, 2009, at 7:57 AM, Jerry Krinock wrote:



On 2009 Mar 21, at 06:46, Luca C. wrote:

Essentially they are the same, but the word value fits nicely  
with KVC.


Yes, but setObject is usually used for dictionaries, although  
there is the variant -setValue:forKey: which handles nil objects,  
unlike -setObject:forKey: which raises an exception.


Is there a method to the madness?


-setValue:forKey: is not a variant of -setObject:forKey:. - 
setObject:forKey: is the method for setting the object for a specific  
key in an NSMutabelDictionary. -setValue:forKey: is a method declared  
by the NSKeyValueCoding informal protocol implemented in NSObject that  
sets a property value for any NSObject subclass.  There is not likely  
anything more special in the naming use than that.


In fact, the docs for NSMutableDictionary's setValue:forKey: say:  
This method adds value and key to the receiver using  
setObject:forKey:, unless value is nil in which case the method  
instead attempts to remove key using removeObjectForKey:.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Bindings: which object+property is being edited?

2009-03-17 Thread Keary Suska


On Mar 17, 2009, at 2:18 PM, Jim Correia wrote:

Given an NSObjectController subclass, or an NSManagedObjectContext  
(with chained controllers), is it possible to determine the set of  
objects + properties currently being edited?


The NSEditorRegistration protocol is untyped:

- (void)objectDidBeginEditing:(id)editor;
- (void)objectDidEndEditing:(id)editor;


and the editor is often an instance of a private class.



IIRC you can determine which view is being edited (i.e. what view an  
editor is associated with), but I don't believe Cocoa has any concept  
of properties being edited. If you can get the view, you can inspect  
its bindings, but that seems a rather roundabout way to do something  
that might have a smarter approach.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: How to create an NSDecimal?

2009-03-15 Thread Keary Suska


On Mar 14, 2009, at 6:32 PM, Michael Ash wrote:

On Sat, Mar 14, 2009 at 6:55 PM, Keary Suska cocoa-...@esoteritech.com 
 wrote:

On Mar 14, 2009, at 2:35 PM, Ashley Clark wrote:

I don't see NSDecimalFromString() in any of the docs or header  
files, only

NSDecimalString() to create strings. Where is that defined?


It's part of Foundation, defined in NSDecimal.h.


It's not in any of the copies of NSDecimal.h on *my* system  
(10.5.6)



Hmm, I can't find it either. Anyway, this was a function in  
NSDecimal.h that was part of NextStep that is still part of GnuStep,  
but must have been removed by Apple at some point.


Sorry,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSProgressIndicator's setUsesThreadedAnimation only works sometimes?

2009-03-14 Thread Keary Suska


On Mar 13, 2009, at 4:20 PM, Sean McBride wrote:


Hi all,

I'm trying to make a cheap, modal, indeterminate progress dialog, but
I'm having trouble animating the progress bar.

(Yes, I know this is only slightly better than the spinning wheel of
death.  Yes, I know I should thread my long running code.  Yes, I  
know I

should not block the main thread.  One day...)

The docs for NSProgressIndicator's setUsesThreadedAnimation say This
value is only a hint and may be ignored.  Indeed, sometimes it  
animates

and sometimes it does not.  I can't find any pattern.

Is there a way to reliably make an NSProgressIndicator animate while  
the

main thread is blocked?



I have had success using -beginModalSessionForWindow: and an NSTimer  
that calls a method that checks for an end condition and calls - 
runModalSession:.


I have mostly used this in cases where I needed asynchronous behavior  
but I need to block the UI.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: How to create an NSDecimal?

2009-03-14 Thread Keary Suska

On Mar 14, 2009, at 2:35 PM, Ashley Clark wrote:

I don't see NSDecimalFromString() in any of the docs or header  
files, only NSDecimalString() to create strings. Where is that  
defined?


It's part of Foundation, defined in NSDecimal.h.


On Mar 14, 2009, at 2:08 PM, Luca Pazzerello wrote:


You can also create NSDecimals using NSDecimalFromString().
--Luca C.

2009/3/14 Ashley Clark acl...@ghoti.org


You can get an NSDecimal structure from any NSNumber or  
NSDecimalNumber
object by sending it the -decimalValue message. As far as I know  
that's the

only way to create one.



Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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 to selection of NSArrayController manually

2009-03-13 Thread Keary Suska


On Mar 13, 2009, at 9:42 AM, Ivy Feraco wrote:


Hello everybody

Bindings problem:

I have an NSArrayController subclass and an NSPopUpButton subclass.
I am trying to bind the NSPopUpButton's selected object to the  
selection of my array controller.

I have to do this manually for reasons I won't get into here.

But when I do this (self is myPopUpButton)
[self bind:@selectedObject toObject:ArrayController  
withKeyPath:@selection options:nil];


I get the error that my array controller is not KVC for the key path  
selection.
selection is definitely a controller key option  in Interface  
Builder, is it possible that this doesn't work programmatically?

Has anyone else run into this problem???

I want to bind to the selected object, not the index... so it seems  
my only option here is selectedObjects, which I will have to pass an  
array of one object to.



Even if you didn't get the error, this approach wouldn't work. The  
selectedObject must be an exact object from the content collection. - 
selection returns a proxy object. You might try barking up using  
selectedValue instead. But then, you might still have the binding  
error, or it might go away since you are binding through selection.  
Anyway, have you verified that the ArrayController variable is what  
you expect it to be at the point that bind: is called?


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSObjectController selection - now you see it, now you don't

2009-03-08 Thread Keary Suska


On Mar 7, 2009, at 11:05 PM, Luke Evans wrote:

Well, what actually happens is that -selectedObjects almost always  
returns an empty array.  Sending -setContent: does not appear to  
result in this content being available as the selectedObject in the  
way described (or there's other magic to get this to happen?).

snip

- (void)awakeFromNib {
[objController setContent:@This is a nice string];
NSArray *selectedObjects = [objController selectedObjects];
	id selectedObject = (selectedObjects  [selectedObjects count])?  
[selectedObjects objectAtIndex:0] : nil;
	NSLog(@The selectedObjects were: %@,\n the selectedObject was:  
%@, selectedObjects, selectedObject);


[objController setContent:@Another string];
selectedObjects = [objController selectedObjects];
	selectedObject = (selectedObjects  [selectedObjects count])?  
[selectedObjects objectAtIndex:0] : nil;
	NSLog(@The selectedObjects were: %@,\n the selectedObject was:  
%@, selectedObjects, selectedObject);

}


What happens when this is run is that the first time -setContent: is  
used, the -selectedObjects method returns the object (the string).


The second time however, has -selectedObjects return NO object (i.e.  
the empty array).


IIRC, NSObjectController, as a super class has some behavior that  
doesn't make sense to an NSObjectControlelr proper. Because of this it  
is possible that the selection change has been deferred to the run  
loop. You can manually run the run loop to see if this is the case.


It seems to me that there is no need for you to use -selectedObjects  
when there will always be a 1:1 relationship between the controller  
content and the selected object.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSObjectController selection - now you see it, now you don't

2009-03-08 Thread Keary Suska


On Mar 8, 2009, at 2:20 PM, Luke Evans wrote:

IIRC, NSObjectController, as a super class has some behavior that  
doesn't make sense to an NSObjectControlelr proper. Because of this  
it is possible that the selection change has been deferred to the  
run loop. You can manually run the run loop to see if this is the  
case.


It seems to me that there is no need for you to use - 
selectedObjects when there will always be a 1:1 relationship  
between the controller content and the selected object.



Yes, naturally if I change my selection code to just look at the  
content then indeed everything works fine.   However, see below...
I'm not sure about the run loop thing.  Although I haven't tried  
this in my test app yet, the behaviour in the main app seems to  
suggest that changing the content object never updates the  
selectedObjects array, except perhaps for the very first time.



After setting the content, but before you check selectedObjects, run:

[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];

If that works, then you have the runloop issue. Otherwise, it is  
probably a bug and I would file a radar.


Just know that there may be caveats to forcing the runloop like this,  
so caveat programmor.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Can an object observe itself?

2009-03-07 Thread Keary Suska


On Mar 7, 2009, at 1:31 PM, Stuart Malin wrote:

I have a model class with multiple properties. I need to know in a  
variety of places when certain of these change. Presently, the model  
objects can be changed by an inspector that has bindings to the  
model instances, which are managed as a collection by an  
NSArrayController. So... I tried adding code to the model object to  
observe itself (on a key that is a dependent key set up with  
+setKeys:triggerChangeNitificationsForDependentKeys). I was then  
going to have that observer issue a notification. However, the  
model's -observeValueForKeyPath:ofObject:change:context: method  
isn't getting called when I make changes. Thinking the problem was  
with the dependent key, I changed to observe a specific key. That  
doesn't work either. So I am wondering if an object can observe  
itself.  I add the observer in the model object's -init method,  
after invoking -init on the superclass:



The main issue is that you have to remove observation before  
deallocating. Otherwise an exception will be raised (Leopard) or you  
will crash (Tiger and earlier).


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSString leak or RedHerring again?

2009-03-05 Thread Keary Suska


On Mar 5, 2009, at 12:26 PM, James Cicenia wrote:


OK That worked but now that I got you:

Why is it complaining about  the indicated array below:



while (sqlite3_step(statement) == SQLITE_ROW) {
//find subtype as key in the dict first
if(![aDict objectForKey: [NSString stringWithUTF8String:(char  
*)sqlite3_column_text(statement, 2)]]){


	NSMutableArray *tmparray = [[NSMutableArray alloc]init];   
== =  Says it leaks?


	[aDict setValue:tmparray forKey: [NSString stringWithUTF8String: 
(char *)sqlite3_column_text(statement, 2)]];

[tmparray release];
}


May be a false positive, unless there is other code that may cause it  
to leak. But, the following:


subtypeArray = [aDict objectForKey: [NSString stringWithUTF8String: 
(char *)sqlite3_column_text(statement, 2)]];
[subtypeArray addObject: [NSString stringWithUTF8String:(char  
*)sqlite3_column_text(statement, 0)]];
[aDict setValue:subtypeArray forKey: [NSString stringWithUTF8String: 
(char *)sqlite3_column_text(statement, 2)]];

}



If subtypeArray is mutable, as it appears to be, the last statement is  
useless and potentially dangerous.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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


Bindings: Why Doesn't Key Value validation Update The UI?

2009-02-16 Thread Keary Suska
I can't imagine why I haven't come across this before but it appears  
that when a key-value validation method alters the passed object and  
returns YES, the view is not updated with the coerced value.


I need behavior, for instance, where an NSTextField is supposed to  
display a numerical value that if the field is cleared that it is re- 
set to 0. Sounds simple, but I can't get it to work. Calling a KVC  
setter in validateKey (which could be bad) doesn't cause the update.  
Neither doing the same in the setter (also sounds like a bad idea  
anyway).


It seems like I have two options: set a transformer (that is really  
acting like a validator) or trick bindings with a change-value-for-key  
notice triggered using performSelector:afterDelay:.


Anyone have any better ideas?

TIA,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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 Popup Column issue

2009-02-06 Thread Keary Suska


On Feb 6, 2009, at 8:47 AM, Jon C. Munson II wrote:

The issue is that the popup displays a left paren, and when the list  
is

displayed, shows the item as an array dump (instead of the proper
attribute's value).  I also cannot select that value and have it  
stick to
the underlying datasource (which is an intermediary table in a  
SQLite store,

provided by Core Data).


This generally means that you are binding a single value  
representation to an array (multiple).



I know the popup is getting the proper values from its supporting
NSArraryController as I removed the binding for the Selected Object  
and the
popup works as expected (minus the saving of the selected object) -  
the
attribute's value is displayed correctly in the list.  The problem  
occurs

when I set the selected object binding.

The Selected Object binding is configured thus:

Bind to:  tblPattern_Yarn
Controller Key:  arrangedObjects
Model Key path: relYarn


And here you do it. Selected Object needs to be bound to something  
that returns a single value. arrangedObjects returns an array. Perhaps  
you want selection?


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: becomeFirstResponder override issue

2009-02-02 Thread Keary Suska


On Feb 2, 2009, at 8:44 AM, Chris Anderson wrote:

Thanks.  And yes the controller has content.  In my example below it  
returns 0 when inside becomeFirstResponder and returns  0 when I  
activate detectPicker in the same application instance.


I was more interested in whether myArrayController is nil when - 
becomeFirstResponder is called. The NSLog below won't tell you that,  
so I wasn't sure if you specifically checked for nil.



On 2-Feb-09, at 7:40 AM, Keary Suska wrote:



On Feb 1, 2009, at 10:32 PM, Chris Anderson wrote:

I've created a subclass of NSDatePicker to catch when a date  
picker has focus. I have overridden the becomeFirstResponder  
method and indeed it detects when it has focus. The code inside  
the method does work except for any IBOutlets that I may have  
connected. They don't respond to any requests.


I have verified that the IBOutlets are connected by adding a  
separate IBAction in the subclass and a simple button to invoke  
the action. Inside the IBAction I can call the same IBOutlets  
successfully.


I am baffled as to why when the IBOutlets are inside  
becomeFirstResponder they don't seem connected. Example below...


-(BOOL)becomeFirstResponder // myArrayController will not respond
{ NSLog(@DetectDatePicker:firstResponder: %i,  
[[myArrayController arrangedObjects] count]);

return YES;
}
-(IBAction)detectPicker:(id)sender // myArrayController  
successfully responds
{ NSLog(@DetectDatePicker:performClick: %i,[[myArrayController  
arrangedObjects] count]);

}



Have you checked whether myArrayController is nil, just whether it  
has content? Those would likely be two separate issues...





Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Disabling sorting in a programatically generated table

2009-01-31 Thread Keary Suska


On Jan 30, 2009, at 10:39 AM, Ken Tozier wrote:



On Jan 30, 2009, at 10:52 AM, Keary Suska wrote:

When you call -bind: do you pass  
NSCreatesSortDescriptorBindingOption NO?


I'm not calling bind, because the array controller and array are  
created inside the same function, so it just seemed bass ackward to  
write an accessor for something I can just set directly with  
[controller setContent: tableData]. I looked at the  
NSArrayController docs again and didn't see any method that  
approximates  NSCreatesSortDescriptorBindingOption other than


[controller setSortDescriptors: nil];
[controller setAutomaticallyRearrangesObjects: NO];



You don't have a binding between the table view and the array  
controller?


Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Disabling sorting in a programatically generated table

2009-01-30 Thread Keary Suska


On Jan 30, 2009, at 1:59 AM, Ken Tozier wrote:


Hi

I need to completely disable sorting in a programatically generated  
table, but have found that no matter what I try, clicking on the  
column header sorts the table. I've set the following sort  
descriptors to nil


// On the table
[table setSortDescriptors: nil];

// On the column
[column setSortDescriptorPrototype: nil];

// And on the array controller for each column
[controller setSortDescriptors: nil];
[controller setAutomaticallyRearrangesObjects: NO];

How do you shut down all sorting on a table?



When you call -bind: do you pass NSCreatesSortDescriptorBindingOption  
NO?


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: NSFileHandle or a better way?

2009-01-30 Thread Keary Suska


On Jan 30, 2009, at 7:44 AM, Jaime Magiera wrote:

I've been using NSFIleHandle for a project that inserts data into a  
file and synchs it back to disk. Everything went smoothly until the  
app started getting used for larger files (  200 megs). First, I  
ran into the NSFileHandle - NSData 256 megs conundrum. That was  
solved by, as others suggested on this list in other threads,  
iterating with readDataOfLength or availableData  instead of a  
single readDataToEndOfFile. That worked well. I've got pools set up  
to keep the memory down. The problem now is that the reads are still  
really slow. For example, with a read length of 50 megs, I can only  
get in 3 reads per second. My apps ends up taking almost a minute to  
perform all of its functions on a file of 500 megs.


Perhaps my overall approach was wrong to start out. What I've been  
doing is opening a file handle, copying the data after the insertion  
point to an NSData, truncating the file handle at the insertion  
point, adding the new data, then adding back the trimmed data. This  
works fairly well if the insert point is towards the end of the  
file. However, there are instances where I need to insert a few  
hundred kb into a the file at a location only a few hundred kb into  
the file.


xxx ^ x

The time hit comes from copying the trim data to the NSData. Is  
there a better way to do this with NSFileHandle?  Is there a better  
way to do this than NSFileHandle?


I suspect your bottleneck is the filesystem. To know for sure you  
could try the raw C calls and see if it speeds up. In any case,  
instead of doing a grow/shrink on the file, write to a temp file  
instead then swap them. This way you could also do optimized batch- 
writes. This alone could speed the process up immensely.  
Notwithstanding, how do you recover if your app crashes after you  
truncate the file?


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: sqlite iphone question....

2009-01-23 Thread Keary Suska


On Jan 23, 2009, at 10:30 AM, James Cicenia wrote:


- (void)initializeDatabase {
NSMutableArray *items = [[NSMutableArray alloc] init];
self.produceItems = items;
[items release];

// The database is stored in the application bundle.
   NSArray *paths =  
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
NSUserDomainMask, YES);

   NSString *documentsDirectory = [paths objectAtIndex:0];
   NSString *path = [documentsDirectory  
stringByAppendingPathComponent:@whatsfresh.sqlite];


	// Open the database. The database was prepared outside the  
application.

   if (sqlite3_open([path UTF8String], database) == SQLITE_OK) {
NSLog(@Open Database);
// Get the primary key for all produce.
const char *sql = SELECT id FROM Item;
   sqlite3_stmt *statement;
   // Preparing a statement compiles the SQL query into a byte- 
code program in the SQLite library.
   // The third parameter is either the length of the SQL string  
or -1 to read up to the first null terminator.
   if (sqlite3_prepare_v2(database, sql, -1, statement, NULL)  
== SQLITE_OK) {


NEVER GETS PAST THIS IF. I have queried the database and the data is  
in there?!



Working with files in the app bundle like this may be a non-no. At  
least, it is for Mac OS X, and the emulator might have this issue. To  
know for sure, put the database file into the sandbox and see if it  
behaves better there.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Encryption: Simplest method to encrypt a SQLite DB file...? {iPhone}

2009-01-23 Thread Keary Suska


On Jan 23, 2009, at 9:41 AM, fc...@dialup4less.com wrote:


Environment: iPhone

I'm particularly concerned with 'data viewing'.
Think of the data as answers to a quiz.   I worry that some
hacker could copy  distribute the data (rules) on the internet, and  
in essence,

cheat  the game.

Being that ... iPhone is far more restrictive towards tampering...,
Is it still possible to grab the SQLite DB file from the bundle to  
view its (uncoded) data?
If not, then there's no need to encrypt the SQLite DB file within  
the App Bundle.



Also consider the iPhone backup with iTunes onto the Mac. Not sure how  
difficult those archives are to crack, or whether any attempt has even  
been made to prevent it.


Best,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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: Search Fields, Array Controllers and Multiple NIBs

2009-01-20 Thread Keary Suska


On Jan 19, 2009, at 9:58 PM, Brad Gibbs wrote:

I have a Core Data app with a container view controller and multiple  
subviews, each with a view controller and a separate NIB.  Subview  
switching is done via a segmented control.  The subviews each  
display the same data, but in different ways -- one is a table view,  
another is an image view and the third is a cover flow view.


The container view displays the segmented control that does the  
switching and a search field that is used to filter what is shown in  
the subviews.  My aim is to have the search field filter the three  
views equally, such that if the user performs a search, all three  
subviews will show the filtered results of that search.  So, the  
user the perform the search and each of the three views will display  
the filtered results of the same search.


I've tried a number of approaches.  To me, it seems the most logical  
approach is to have the container view pass its MOC and  
NSArrayController instance to each of the subviews as it creates  
them.  I still need to create an NSArrayController instance in each  
view's NIB file in IB to bind the objects in each of the views, but  
I can create an outlet in each view controller and set it to the  
NSArrayController instance passed in from the main view when the  
subview is instantiated.  But, this doesn't seem to work.  I can  
NSLog each array controller to see that each view has the same  
instance of the NSArrayController, but searching in the main view  
doesn't seem to filter any of the subviews properly.


If I understand this correctly, you have an NSArrayController  
instantiated in the nib, and one created programmatically. If they  
aren't connected in some way, there is no way for the filtered  
NSArrayController to communicate its changed contents to the nib-based  
controller, so the display never changes.


One better solution, I think, is to not use bindings at all for the  
search field. Instead, connect it to the main controller (target/ 
action is probably best), who on execution sets a filter predicate  
that is a property bound from the NSArrayController in the nib. Or, if  
you already have outlets to the NSArrayController, you can just call - 
setFilterPredicate:.


HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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


<    1   2   3   4   5   6   7   8   >