Re: addsubview

2012-04-19 Thread Keary Suska
On Apr 19, 2012, at 5:34 PM, koko wrote:

> I get the view for an NSTabViewItem.
> 
> To this view I add a subview.

How do you (in code) identify the correct NSTabViewItem, retrieve the view and 
add the subview? What is the frame of the subview?

> In the debugger displaying the subviews of view I see the subview.

How do you know it is the correct/same subview?

> When  the NSTabViewItem displays  the subview is not being shown.  The view 
> does display.
> 
> The subview is not set hidden in IB.
> 
> Why would I not see the subview?



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

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


Re: Debugging NSWindowController and NSArrayController

2012-04-11 Thread Keary Suska
On Apr 11, 2012, at 11:49 AM, Rui Pacheco wrote:

> Prepares content is checked, Uses lazy fetching is not - setting it doesn't 
> change anything. I called -fetch: on gdb and the result was nil. 
> managedObjects returns an empty array.

Have you verified that the array controller is using the same MOC that you use 
in your -init and -windowDidLoad?

> On 11 April 2012 19:12, Keary Suska  wrote:
> On Apr 11, 2012, at 7:04 AM, Rui Pacheco wrote:
> 
> > Hi,
> >
> > I have an NSWindowController that creates an instance of
> > NSManagedObjectContext. That window controller loads a NIB that has a table
> > populated by an NSArrayController bound to the MOC in the window
> > controller. This was done via Interface Builder. The array controller is
> > set to retrieve Entities of type X.
> >
> > On the init method of my window controller I add an object of type X to the
> > MOC and I can see it's there because I can fetch it on windowDidLoad but
> > for some reason the array controller on the NIB doesn't see any data. If I
> > fire up gdb and do *po [arrayController arrangedObjects]* I get an empty
> > array.
> >
> > Is there any other way of debugging this?
> 
> 
> Is "Prepares content" checked? Is "Uses lazy fetching" checked? Do you have a 
> predicate specified, and does the object match the predicate? What happens 
> when you tell the array controller to -fetch:?

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

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


Re: Debugging NSWindowController and NSArrayController

2012-04-11 Thread Keary Suska
On Apr 11, 2012, at 7:04 AM, Rui Pacheco wrote:

> Hi,
> 
> I have an NSWindowController that creates an instance of
> NSManagedObjectContext. That window controller loads a NIB that has a table
> populated by an NSArrayController bound to the MOC in the window
> controller. This was done via Interface Builder. The array controller is
> set to retrieve Entities of type X.
> 
> On the init method of my window controller I add an object of type X to the
> MOC and I can see it's there because I can fetch it on windowDidLoad but
> for some reason the array controller on the NIB doesn't see any data. If I
> fire up gdb and do *po [arrayController arrangedObjects]* I get an empty
> array.
> 
> Is there any other way of debugging this?


Is "Prepares content" checked? Is "Uses lazy fetching" checked? Do you have a 
predicate specified, and does the object match the predicate? What happens when 
you tell the array controller to -fetch:?

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

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


Re: Question about hebrew in textfields and textviews

2012-04-11 Thread Keary Suska
On Apr 11, 2012, at 9:36 AM, Matthew Weinstein wrote:

> Working with a person using hebrew input method. Text appears right-to-left 
> as desired, but all of the textfields and textviews are still left justfiied, 
> so it looks a little weird. Is there something I need to do so that when 
> users are using Arabic or Hebrew everything justifies the other way?

I believe there is an expectation that you use localized xibs. If you are, have 
you specified the correct justification in the xib? If you don't need localized 
xibs, you may be able to get the desired behavior by calling the method 
-setBaseWritingDirection:, although there may be other and better ways.

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

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


Re: recalculateKeyViewLoop doesn't work

2012-03-29 Thread Keary Suska
On Mar 29, 2012, at 5:47 AM, Nava Carmon wrote:

> Hi
> 
> In my cocoa application I want to change the key order of my views. I fill in 
> the nextKeyView reference for all subviews in the desired order. In the 
> view's awakeFromNib function I do the following:
> 
>[[self.view window] setInitialFirstResponder:self.view];
>[[self.view window] setAutorecalculatesKeyViewLoop:NO];
>[[[self view] window] recalculateKeyViewLoop];
> 
> where the nextKeyView for the self.view is set to the first subview I want to 
> appear in key order.
> 
> Nothing helps and the the key ordering stays default. How to resolve it?

-recalculateKeyViewLoop is in fact ding what it is supposed to. You call this 
method to have the system determine the key-view loop for you. If you want your 
own ordering, that is not geometrical, you need to avoid 
-recalculateKeyViewLoop.

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

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


Re: Disable PDFView context menu

2012-03-26 Thread Keary Suska

On Mar 26, 2012, at 3:36 PM, Nick wrote:

> Is there a way to disable this of filtering, to make the PDFView
> subclass receive the -rightMouseDown event?.. Or what would be the
> workaround (if it exists)?..

If you are targeting 10.6 or later you can install an event monitor (see the 
NSEvent class reference). You could also subclass NSWindow and use use that 
subclass in the enclosing window as it should receive the event first.

There may be event handling routines in Core Foundation that provide the kind 
of control that PDFView is exerting but that is beyond my know-how.

>> AFAIK you shouldn't get a mouseDown call for a right click, only a left 
>> click, but you can verify that with breakpoint. It is likely the event is 
>> being filtered out higher in the event handling chain...

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

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


Re: Disable PDFView context menu

2012-03-26 Thread Keary Suska
On Mar 26, 2012, at 12:41 PM, Antonio Nunes wrote:

> On 26 Mar 2012, at 19:09, Nick wrote:
> 
>> However, I still can't receive -rightMouseDown message. I am returning
>> "nil" in the method -(NSMenu*)menuForEvent, which disabled the context
>> menu.
>> But how can I process right-mouse-button clicks?..
> 
> PDFView doesn't play very nice with clicks. If you allow PDFView to intercept 
> a mouseDown (i.e. not overriding it), then you pretty much lose control over 
> the whole click tracking. I suppose you can override mouseDown: and query the 
> event for buttonNumber and use that to recognize a right mouse down 
> (NSRightMouse). (Haven't tried this myself though.) 


AFAIK you shouldn't get a mouseDown call for a right click, only a left click, 
but you can verify that with breakpoint. It is likely the event is being 
filtered out higher in the event handling chain... 

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

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


Re: Disable PDFView context menu

2012-03-26 Thread Keary Suska
On Mar 26, 2012, at 11:04 AM, Nick wrote:

> Hi.
> I am wondering, if it is possible to disable a context (popup) menu
> for a PDFView control?
> I have subclassed it, and overridden mouseDown and rightMouseDown.
> I am receiving mouseDown event. But I do not receive rightMouseDown, I
> am getting context menu displayed instead...

I suspect you need to override +defaultMenu or -menuForEvent:, depending on 
what you need to accomplish.

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

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


Re: NSMatrix, NSForm - addRow - why above and not below?

2012-03-13 Thread Keary Suska
On Mar 13, 2012, at 8:55 AM, Grandinetti Philip wrote:

> I'm running into a strange behavior with NSForm (and also NSMatrix).
> 
> (1) Using interface builder (in Xcode 4.3.1) I place an NSForm in a window. I 
> add a NSButton and wire it to an IBAction that sends addRow to the NSForm.
> 
> - (IBAction) addRow:(id)sender
> {
>[form addRow];
>   [form sizeToCells];
> }
> 
> The problem is that the new row is added ABOVE the existing row, not below as 
> it's supposed to. I thought this was a problem coming from somewhere else in 
> my app, but I created a new project in Xcode and this happens even in the 
> simplest app.
> 
> I must be doing something stupid wrong, but I can't find it. Any suggestions 
> would be appreciated.


It is a bit deceptive, but the problem is not what you think. The row is in 
fact added at the bottom, but when the view is resized it is sized from the 
bottom left corner, instead of the top left, which is intuitive for humanity 
but not apparently for the founders of Cocoa.

To get the behavior you expect you need to either flip the coordinate system of 
the enclosing view or move the view back as such:

- (IBAction) addRow:(id)sender
{
  NSRect originalFrame = [form frame];
  [form addRow];
  [form sizeToCells];
  NSRect newFrame = [form frame];
  CGFloat delta = newFrame.size.height - originalFrame.size.height;
  newFrame.origin.y -= delta;
  [form setFrame:newFrame];
}

Note that -sizeToCells does not cause the view to be redrawn, so you will get 
drawing artifacts. You may use -selectTextAtIndex: to set focus on the new form 
field, which will avoid the drawing issues (maybe a little more functional than 
just calling -setNeedsDisplay:).

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

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


Re: Finding object array index when iterating through array

2012-03-07 Thread Keary Suska
On Mar 6, 2012, at 1:42 PM, Prime Coderama wrote:

> I have an array and I am iterating through it using this technique:
> 
>> for (id object in array) {
>>// do something with object
>> }
> 
> Is there  way to obtain the object's current array index position or do I 
> have to add a counter?


You have to track that yourself. If you need the index a lot of the time, then 
do an iterated loop. If you need it rarely, just look it up using 
-indexOfObject:. Either way, the performance difference is probably negligible.

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

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


Re: textfield problem

2012-03-02 Thread Keary Suska
On Mar 2, 2012, at 1:35 PM, H. Miersch wrote:

> i have a problem with a text field that won't accept any input. the textfield 
> is one of three on a panel that appears only when the input is needed. I 
> activate the panel with this line:[app beginSheet:Sheet 
> modalForWindow:mainWindow modalDelegate:self didEndSelector:NULL 
> contextInfo:nil];
> 
> in IB, behavior is set to editable, state is enabled. i've tried deleting the 
> textfield and replacing it with a new one, i've tried [textfield 
> setEditable:YES], but no joy. the textfield stubbornly refuses to accept any 
> input. when i click it, nothing happens. when i double-click it, any existing 
> characters are highlighted in grey instead of blue, and if i type anything, 
> that input goes to whatever was active before the double-click. i'm obviously 
> doing something wrong, but i have no idea what. can anyone point me in the 
> right direction?

Do you have a value binding for the field? If so, is "Conditionally sets 
editable" checked?

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

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


Re: HELP!! Big problem with relationships and saving in iOS core data

2012-03-01 Thread Keary Suska
On Mar 1, 2012, at 2:39 PM, Eric Giguere wrote:

> In a button handler, I create an object A, then a child B then and child C to 
> B.
> Save this whole thing, all is ok.

The key issue here is, *how*? We would need to see your code to make sure you 
are establishing the relationships properly...

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

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


Re: Who is responsible for removing observers in longer key paths

2012-03-01 Thread Keary Suska
On Mar 1, 2012, at 12:26 PM, Per Bull Holmen wrote:

> In my current project I have a controller object, that the view can
> bind to, with the following key path:
> 
> parameterInfo..
> 
> "parameterInfo" is a literal key name,  maps to a
> parameter in a plug-in, and must be resolved at run-time.
>  is one of several attribute names, such as "minValue",
> "maxValue" etc. There is a value object that represents parameterInfo,
> which is of class PBH_ParameterInfo. Since the information in the tree
> rarely changes, I thought it would be easier to make it immutable, so
> the parameterInfo object will return the same (pointer equal)
> NSDictionary object for each key throughout its entire lifetime. When
> the info in the tree changes, the controller just makes a new
> parameterInfo instance, and replaces the entire tree with [self
> setParameterInfo:newParameterInfo]. What happens then is:
> 
> 1) The view correctly updates, meaning it must have received the notification.
> 2) The old parameterInfo object is correctly deallocated.
> 3) I get an error in the console saying the parameterInfo object is
> being deallocated while there are still observers attached.
> 
> These observers are clearly registered under-the-hood by NSObject's
> (?) implementation. When the controller object is asked to register an
> observer for the key path parameterInfo.linearGain.maxValue, it goes
> to the next property in the chain (parameterInfo), and registers some
> sort of proxy pbject as an observer for linearGain.maxValue. So my
> question is who is responsible for removing the observation when it is
> no longer needed, and how shall I make it happen The Right Way? The
> old object is being deallocated by NSAutoreleasePool, so all observers
> are already notified that the parameterInfo property has changed.
> Shouldn't NSObject's implementation already know that the observation
> is no longer needed? After all, the old PBH_ParameterInfo instance is
> no longer part of the original key path being observed.

It is the responsibility of the observer to remove observation. The bindings 
system handles this automatically, but not always on your timetable so you 
could end up deallocating an object before the observers have updated. How/why 
I can't tell you, but I have run into this issue myself. I don't recall 
specific but if memory serves me, you can work around this issue by putting an 
NSObjectController in the xib whose purpose is to manage the PBH_ParameterInfo 
object, and change its content when you need to change the 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: HELP!! Big problem with relationships and saving in iOS core data

2012-03-01 Thread Keary Suska
On Mar 1, 2012, at 7:12 AM, Eric Giguere wrote:

> I'm on the verge of loosing my sanity... I've been running after save bugs 
> and I'm now completely out of ideas, other than to drop Core Data.
> 
> In my model, I have EntityA, wich has an 1-many relationship to EntityB, 
> which also have a 1-many relationship to EntityC.
> Both relationship are bi-directionnal, and I'm using cascade delete from A to 
> C.
> 
> The only object in that chain that seems to be deletable is EntityB.
> As soon as I try to delete an object from EntityC (A -> B -> C), I get this 
> error:
> Terminating app due to uncaught exception 'NSObjectInaccessibleException', 
> reason: 'CoreData could not fulfill a fault for
> 
> I've been hitting this error for a long time now. I've read that it may be 
> because I may have a reference in my code to the object that get deleted. So 
> I cleaned up everything, nothing does.
> So out of despair, I've created a small method in my main window that creates 
> a new tree of object (A contain 1 B, contains 1 C) and try to delete C. No 
> references anywhere here.
> 
> If I try deleting the C object before saving the new stuff, I get this error:
> Domain=NSCocoaErrorDomain Code=134030 "The operation couldn’t be completed. 
> (Cocoa error 134030.)
> NSUnderlyingException = "Cannot update object that was never inserted.";
> 
> And if I save, then delete then save again I get back to the 
> NSObjectInaccessibleException.
> 
> 
> Anybody, please, if you have a pointer so that I could find and fix this 
> error... It does not make sense that such a library fails with such a trivial 
> case.
> I must be doing something wrong, but I've re-re-re check everything and don't 
> see.
> 
> I've played with the reverse relationship delete rules, made all of the 
> optional, put them to nil before saving, nothing does :(

There may not be enough information here but I take a shot. Are you suing only 
one managed object context? Multiple contexts do *not* automatically sync, so 
if you don't handle this yourself you will run into similar problems. Does C 
have any relationship to A? Is C loaded directly or through B, and B likewise 
trough A? Or, if all objects are new, are you properly adding each object to 
the relationship (that also doesn't happen automatically, although properly 
bound NSArrayControllers will do this for you)?

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

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

Re: How do IB inspector fields relate to the actual objects?

2012-02-29 Thread Keary Suska
On Feb 29, 2012, at 12:03 PM, Howard Moon wrote:

> Hi,
> 
>   I've added a Panel to a nib for an audio plug-in I'm working on, and am 
> having trouble determining how the IB Inspector settings relate to the actual 
> objects, such as an NSPanel.  In the Inspector, there are several Style Mask 
> checkboxes:
> 
>   Utility
>   HUD
>   Non Activating
>   Document Modal.
> 
>   What do those mean?  The tool tip for those says they relate to the 
> member styleMask.  Yet when I look up the NSWindow member styleMask, it leads 
> me to a link to the page "Window Style Masks", which lists the following 
> values:
> 
>   NSBorderlessWindowMask
>   NSTitledWindowMask
>   NSClosableWindowMask
>   NSMiniaturizableWindowMask
>   NSResizeableWindowMask
>   NSTexturedBackgroundWindowMask
> 
>   I don't see what the relation between these is.  Is there any?  Is it 
> documented anywhere?  I've spent an hour searching and can't find *anything* 
> that says what those Inspector fields mean (other than the aforementioned 
> tool-tip).
> 
>   I'm trying to show a panel that I've loaded previously from my nib. I 
> don't want the panel to show until I want it, and I need to show it via code 
> (in an NSWindowController-derived class I created).  But it either shows when 
> it loads, or it doesn't show at all (when calling showWindow:nil), depending 
> on whether I've checked the "Visible at Launch" checkbox in the IB Inspector. 
>  I was hoping one of those "style mask" properties might be the culprit, but 
> I don't know what they do.
> 
>   Can someone guide me here, or point me to the appropriate 
> documentation?  (My book, Cocoa Programming for Mac OS X, Third Edition, is 
> no help here.)

NSPanels, although subclasses of NSWindow, are their own objects and have their 
own docs. Look into the "constants" section of the NSPanel Objective-C 
reference.

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

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


Re: Question about KVC-compliance and bindings

2012-02-28 Thread Keary Suska
On Feb 28, 2012, at 10:47 AM, Per Bull Holmen wrote:

> Binding to the VALUES did still turn out pretty well now. But the
> Audio Unit plugin API also has a standardized way for Audio Units to
> give the hosts and GUI some static information about each parameter
> such as min/max value, readonly or writable etc. To be able to bind to
> this information too, it would be much easier for me to let the
> controller just fetch this information on the fly, and notify
> observers the few times it changes. Building a tree in memory would
> require more bookkeeping, and would be harder because the controller
> can not know in advance what string keys (which maps to parameters
> IDs) it will be queried for, the controller is supposed to not have
> any knowledge in advance of the possible model keys. But yeah, I'll
> solve it either way. So now I know, there is no shortcut, I must make
> every property on the key path KVC and KVO compliant. I'm not
> complaining... :)

I don't have much to add to Quincy's response--overriding 
-valueForUndefinedKey: is a good approach. I would say that there really isn't 
anything wrong with the controller knowing ahead of time what keys in the model 
will be needed by the UI. In fact, it needs to, and in fact does when you 
establish a binding. It is simply abstract enough that it is easy to forget ;-)

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

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


Re: Question about KVC-compliance and bindings

2012-02-28 Thread Keary Suska
On Feb 28, 2012, at 11:46 AM, Mike Abdullah wrote:

> On 28 Feb 2012, at 17:05, Keary Suska wrote:
> 
>> I find it more useful to focus on KVO (Key Value Observing) compliance 
>> rather than KVC compliance, as although KVC compliance ensures KVO 
>> compliance, the reverse is not always true. 
> 
> Whoah! Wrong way round! To be KVO-compliant, you must be KVC-compliant too. 
> There are tons of examples of KVC-compliance without KVO-compliance though.

Although it is always best approach your statement is not completely true. 
Attribute and to-one relationships do not have to be fully KVC compliant to be 
KVO compliant. Consider dynamic/dependent properties as the most obvious 
example: they do *not* require a -set method to be mutable. You don't even 
need to use the automatic dependent key tracking. There are even necessary 
reasons to bypass pure KVC, which is at least one reason that 
willChange/didChange exist at all. And further if you decide to override the 
KVC methods (-valueForKey: etc) you are bypassing KVC compliance significantly. 

Given that, you point is well taken that my advice may be poor for those who do 
not understand KVC compliance sufficiently, but on the other hand I don't see 
any problem with the logic of going in reverse--i.e. first determining what 
needs to be KVO compliant and then ensuring that compliance, which most often 
includes ensuring KVC compliance but not always, especially when one wants 
dynamic properties without ivar/property backing, which may have been a 
solution for the OP.

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

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


Re: Question about KVC-compliance and bindings

2012-02-28 Thread Keary Suska
On Feb 28, 2012, at 8:24 AM, Per Bull Holmen wrote:

> Suppose I want to make a controller, which allows a view to bind to the 
> keyPath:
> 
> mainBranch.subBranch.attribute
> 
> There will be a large range of theoretical subBranch.attribute
> combinations, but only a few of these will actually be bound to by the
> user. Other combinations will therefore be uninteresting. The
> attributes will be read-only and mostly static, values like
> minValue/maxValue or isEditable. No actual control values. Suppose it
> is much easier for me to have my controller produce these attributes
> on-the-fly, in valueForKeyPath:, than to produce a tree structure to
> hold all the information. The attributes will rarely change (typically
> once per session), and when they do, the entire mainBranch will be
> switched out.
> 
> My question is: Must I ensure KVC-compliance for every subpath of the
> key path? So that querying the controller for mainBranch.subBranch
> MUST return a KVC-compliant object with all the attributes, and
> querying for only mainBranch MUST return an object that can be queried
> for subBranch.attribute, or only subBranch etc...? Even if it doesn't
> make sense to bind anything to these subpaths?

I find it more useful to focus on KVO (Key Value Observing) compliance rather 
than KVC compliance, as although KVC compliance ensures KVO compliance, the 
reverse is not always true. That being said, every object on a key path should 
be KVO compliant for the called key. I.e., your controller should be KVO 
compliant for the key "mainBranch", that returned object must be KVO compliant 
for the key "subBranch", and that object in turn should be KVO compliant for 
the key "attribute."

This all leads to a question, though, which is: what is the problem you are 
trying to solve? Is this a case of premature optimization? Why not just have 
the whole tree in memory?

Overriding KVC methods is rarely a good way to go, especially if performance is 
a concern. If you want dynamism and scalability, you have a good case for using 
Core Data.

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

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


Re: sudden errors

2012-02-27 Thread Keary Suska
On Feb 27, 2012, at 4:53 PM, H. Miersch wrote:

> 
> On 27. Feb 2012, at 23:01, H. Miersch wrote:
> 
>> hi.
>> my project used to build OK, until today. now xcode keeps throwing errors 
>> like this at me:
>> 
>>  Unknown type name 'ViewManager'
>> 
>> yes, i import ViewManager.h, and no, i didn't change any declarations. is 
>> this a bug in Xcode? 
>> 
>> like i said, until sometime today this used to build ok. what am i doing 
>> wrong?
> 
> PS. cleaning and re-building the project doesn't help, and neither does 
> quitting and re-starting xcode :-(

Are you saying that you have not made any changes whatsoever to the project in 
any way, nor did you change the version of Xcode you were using, but you get a 
slew of errors when you clean/compile?

Otherwise, in most cases, it is programmer error. Are the error messages you 
quote the *only* errors and warnings you are getting? Often, this type of error 
is actually cascading from other errors from an included file. I would 
eliminate all other warnings/errors first. It would also help to see the 
contents of both the ViewManager.h and one of the .m files that imports it and 
reports the error.

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

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


Re: [Obj-C] if (self) vs. if (self != nil)

2012-02-24 Thread Keary Suska
On Feb 24, 2012, at 7:50 AM, Oleg Krupnov wrote:

> An interesting question. The following samples are equivalent in terms
> of compiled code, but which one is more correct from the language's
> point of view?
> 
> self = [super init];
> if (self)
> {
> }
> return self;
> 
> self = [super init];
> if (self != nil)
> {
> }
> return self;

It may really boil down to a stylistic issue, but I believe that the "self != 
nil" syntax is the most canonical.

> I also heard that generally speaking NULL is not necessarily always
> equal to 0 on all architectures.


I don't believe this is the case. There can be funny issues with BOOL types, 
such that BOOL == YES is an inadvisable construct, since your BOOL could be an 
integer of any value.

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

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


Re: text field question

2012-02-24 Thread Keary Suska
On Feb 22, 2012, at 5:59 PM, Rick C. wrote:

> I have a panel with a number of text fields where a user should enter numeric 
> values.  These text fields are setup with Sent on End Editing so that if the 
> user presses enter or tabs or changes text fields the value will be entered.  
> The problem is sometimes a user just types in a value and that's it...no 
> enter, no tab, no changing text fields and the value is never received.  How 
> does everyone else handle this and what can you recommend?  Thanks,


The Interface Builder inspector used to have this issue and it could be really 
annoying. I would commit any values being entered when the panel loses key 
focus, via the delegate method -windowDidResignKey: or listening for 
NSWindowDidResignKeyNotification.

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

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


Re: Was: Re: NSStepper - useless?

2012-02-23 Thread Keary Suska
On Feb 23, 2012, at 10:05 AM, Kyle Sluder wrote:

> On Thu, Feb 23, 2012 at 6:16 AM, William Squires  wrote:
>> From what I've read, the NSStepper has a bug (though practically, you'll 
>> never see it); if one were to click the up or down arrow on the control 2^32 
>> times (assuming it's value is a 4-byte signed int,and is initialized to 0), 
>> it would wrap around (or raise an exception for integer overflow). Probably 
>> not what the user had in mind! Why didn't they just make the NSStepper a 
>> custom view that draws two arrows, and has two sent actions that you can 
>> connect? Or even a variation of NSMatrix with two button cells that look 
>> like arrows. That would avoid the problem entirely, and be more intuitive to 
>> use.
> 
> Because NSStepper is over 20 years old, dating back to when the way to
> push values around was to wire up a control's action to another
> control's -takeValueFrom: method. Besides, all sorts of crazy things
> tend to happen anyway when you try to use UINT_MAX for anything
> useful.


Not to mention that this is really a programmer error. If you don't wan the 
value to overflow, set a sensible maximum. A similar issue could happen from 
any user-entry field. It's the developer's responsibility (IMHO) to set data 
entry constraints.

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

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


Re: Dumb question about radio buttons

2012-02-23 Thread Keary Suska
On Feb 23, 2012, at 6:58 AM, William Squires wrote:

>  I have a custom view with an NSBox containing an NSMatrix of button cells 
> (radio buttons) When I created the NSMatrix, I told it I wanted 3 of them, 
> but in the view hierarchy, I can see the NSMatrix under the NSBox, but it has 
> 4 button cells under it, not the three I asked for - Is this an Xcode/IB 
> screw-up, or do NSMatrix's always add one extra element when making a group 
> of radio buttons? Should I delete the matrix and try again? When I vertically 
> resize the matrix, I always see three cells, so I don't think there's one 
> hidden under there.

The third (usually first in the list, however) cell is the cell prototype, as 
every NSMatrix needs a cell prototype. 

>  Also, even though I set the tag for each button cell (the top one is 0, the 
> next one down is 1, etc...), when I connect them to my
> 
> -(IBAction)baseChanged:(id)sender
> {
> int choice = [sender tag];
> switch (choice)
>  {
>  case 0: // number base is 16 - hexadecimal
>  NSLog(@"user chose hexadecimal");
>  ...
>  break;
> 
>  case 1: // number base is 2 - binary
>  NSLog(@"user chose binary");
>  ...
>  break;
> 
>  case 2: // number base is 10 - decimal
>  NSLog(@"user chose decimal");
>  ...
>  break;
>  }
> self.numberBase = choice;
> }
> 
> I always get, "user chose hexadecimal"! :( (all the buttons generate an 
> action, so it's not that...)

Is it not? Have you inspected what the sender object truly is? Maybe it is the 
matrix, and not the cell?

>  Am I supposed to connect the NSMatrix to the action, and not the individual 
> cells? If so, how do I ask for the cell's tag value?

Considering that the sender is the NSMatrix: [[sender selectedCell] tag]

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

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


Re: NSStepper - useless?

2012-02-23 Thread Keary Suska
On Feb 19, 2012, at 5:11 PM, William Squires wrote:

> Okay, 'nuther dumb question. How do I hook the different arrows in an 
> NSStepper to actions in my view controller? Or how do I ask (id)sender which 
> arrow was clicked?

You can't, at least not specifically, on both counts. All the stepper does is 
increment or decrement a numeric value. That's it. If you keep track of the 
last value set, you can determine whether the value went up or down, which 
would indicate which button was pressed.

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

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


Re: NSPopUpButton not accepting setMenu: from WindowController code

2012-02-18 Thread Keary Suska
On Feb 18, 2012, at 8:37 AM, Erik Stainsby wrote:

> 
> [myPUBtn setMenu:menu] accepted in MyAppDelegate but does not accept 
> setMenu:menu when relocated to an NSWindowController.  I'm thinking there is 
> something I have missed about the loading sequence.

When you call this method, what object do you pass as "owner"? Is the outlet 
connected from the File's Owner, or an object in the same xib?

> - (id)initWithWindowNibName:(NSString *)windowNibName owner:(id)owner {
>self = [super initWithWindowNibName:windowNibName owner:owner];
>if (self) {
>   [self setActionPlugins:[self loadPluginsWithPrefix:@"Action"]]; 
>}
>return self;
> }
> 
> 
> - (void)windowDidLoad
> {
>[super windowDidLoad];
>   NSMenu * menu = [[NSMenu alloc] init];
> 
>   for(RSTrixiePlugin * p in actionPlugins)
>   {
>   NSMenuItem * menuItem = [[NSMenuItem alloc] initWithTitle:[p 
> name] action:@selector(showActionPlugin:) keyEquivalent:@""];
>   [menuItem setRepresentedObject:p];
>   [menu addItem:menuItem];
>   NSLog(@"%s- [%04d] added action menu item for plugin: %@", 
> __PRETTY_FUNCTION__, __LINE__, [p name]);
>   }
>   [actionMenu setMenu:menu];
>   NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, menu);   
> // shows description of populated menu
>   NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[menu 
> itemArray] count]);  // returns 2
>   NSLog(@"%s- [%04d] %lu", __PRETTY_FUNCTION__, __LINE__, [[[actionMenu 
> menu] itemArray] count]);  // returns 2
>   NSLog(@"%s- [%04d] %@", __PRETTY_FUNCTION__, __LINE__, [actionMenu 
> menu]);  // (null)
>   [actionMenu setNeedsDisplay:YES];  // on a whim
> }
> 
> 
> […]
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Odd display of percent character

2012-02-13 Thread Keary Suska
On Feb 13, 2012, at 10:04 AM, Chris Paveglio wrote:

> I'm having an issue with the percent character being displayed as random 
> numbers in an NSAlertPanel (modal). My app has an ivar, "fullString", 
> including the usual property/synthesize getters and setters, there is nothing 
> special about it. fullString is bound to an NSTextField where a user might 
> type "10% off all shoes", or put some text that contains dollar signs or 
> percent signs. Later another method will validate if it's a web address or 
> plain text and display an alert if it's not a web address. At this point I 
> use the usual -stringWithFormat and put the "fullString" text in with some 
> other descriptive text. But if fullString contains a percent character, then 
> the NSAlert displays something like "10254458745ff all shoes". Why is the 
> percent character being turned into some numbers, and it also seems to lop 
> off the space and letter o as well? Using ampersand, dollar sign, and number 
> symbol all display properly.
> FWIW, I am using objective-C++, because my QR code library project is C++ and 
> I need to compile it all the same (first time I've had to do anything like 
> this). Would that be somehow mangling my string in the NSAlert display? If I 
> do NSLog on the string displayed in the NSAlert it also logs properly. So why 
> the discrepancy in the Alert?


% is a format specifier, so you must escape them (by doubling them, "%%") if 
you are using it as a format string, even if what follows the % is not a known 
specifier. In your case, "o" means show an unsigned int in octal and the space 
after the % means pad spaces instead of zeros. The number is being derived from 
whichever parameter is being eaten up by the specifier. If it is an object, it 
is converting the pointer address to an int and then showing it in octal. 
Normally you would get a warning about this, unless you don't have decent 
warnings set...

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

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


Re: How to show last name of user in text field whose first name is selected in popup button

2012-02-03 Thread Keary Suska
On Feb 2, 2012, at 10:50 PM, Devarshi Kulshreshtha wrote:

> I have an array of dictionary which contains two keys- firstName
> and lastName and their values, eg.
> 
> firstName/ lastName
> 
> Steve/ Jobs
> Andre/ Agassi
> Christiano/ Ronaldo
> 
> User interface consists of a pop up button and a text field.
> 
> I am displaying first name of users in pop up button. I am able to show
> first name of the user selected in pop button in the text field by using
> following bindings:
> 
> NSArrayController
> 
> Content Array - AppDelegate - myArray
> 
> NSPopUpButton
> 
> content - Array Controller - arrangedObjects - firstName

This is almost never what you want. Bind content to arrangedObjects without a 
controller key. Then bind contentValues to Array Controller - arrangedObjects - 
firstName.

> selected value - AppDelegate - selectionValue

I would not bind this but instead bind selectedObject. "Value" always refers to 
the displayed value, and in your case that is always the first name. To 
accomplish this, you can bind contentObjects to Array Controller - 
arrangedObjects - lastName.

> NSTextField
> 
> Value - AppDelegate - selectionValue

This will now work as you expect. As a matter of design, it would actually be 
better if your "selectionValue" was the dictionary object that contains the 
names, which is really the logical selection object. You can keep the above 
bindings except unbind contentObjects and change the NSTextField binding to 
AppDelegate - selectionValue.lastName .

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

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


Re: NSPopUpButton Binding Frustration

2012-01-30 Thread Keary Suska

On Jan 29, 2012, at 11:32 PM, Seth Willits wrote:

> This is such a dead simple problem that I think I've encountered a couple 
> times over the years and I don't think I've managed to ever find a solution 
> that works how I want. I'll break this down into an easy specific example.
> 
> 
> Say I have a file type popup in a save sheet for saving an image:
> 
> 
> @property NSString * fileType;
> 
> 
> - (NSArray *)fileTypes
> {
>   return [NSArray arrayWithObjects:(id)kUTTypeJPEG, (id)kUTTypePNG, 
> (id)kUTTypeTIFF, nil];
> }
> 
> 
> - (NSArray *)fileTypeNames
> {
>   return [NSArray arrayWithObjects:@"JPEG", @"PNG", @"TIFF", nil];
> }
> 
> 
> 
> 
> The popup should display the names, but I want the selected item bound to 
> fileType which is one of the UTIs. By my reading of the documentation, this 
> _should be very simple_.
> 
> Bind:
> content -> fileTypes*
> contentValues -> fileTypeNames
> selectedObject -> fileType
> 
> 
> So content provides the list of objects, contentValues provides the 
> corresponding titles for each object, selectedObject determines which object 
> is selected. Sounds simple, never works. I've never been able to figure it 
> out. It seems that if contents provides an array of *strings*, those strings 
> are use as the titles *no matter what*.

NSPopupButton is a strange animal, and this situation is probably not the only 
undocumented behavior. For instance, when using selectedObject, the returned 
object must be an exact object in the content/contentObjects array. -isEqual is 
not enough.

I suspect that NSPopupButton requires that the contentValue always be a path on 
the content object. If you change your code to:

- (NSArray *)fileTypes
{
return [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:(id)kUTTypeJPEG, 
@"uti", @"JPEG", @"name", nil],
[NSDictionary dictionaryWithObjectsAndKeys:(id)kUTTypePNG, 
@"uti", @"PNG", @"name", nil],
[NSDictionary dictionaryWithObjectsAndKeys:(id)kUTTypeTIFF, 
@"uti", @"TIFF", @"name", nil],
    nil];
}

Bind:
content -> fileTypes
contentObjects -> fileTypes.uti
contentValues -> fileTypes.name
selectedObject -> fileType

You will notice that it works. Note that you may also be able to use an 
NSDictionaryController to simplify the code.

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

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


Re: Key Value Observing of NSMutableArray inside an object

2012-01-28 Thread Keary Suska
On Jan 28, 2012, at 2:28 PM, Mikael Wämundson wrote:

> Is there something I need to do with my class DataObjectCollection to make 
> the observing work, i.e. to make it KVO compliant?

Implement and use collection accessor methods:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB

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

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

Re: NSTask terminates when NSApplication exits

2012-01-19 Thread Keary Suska

On Jan 18, 2012, at 2:27 PM, Ken Thomases wrote:

> On Jan 18, 2012, at 3:13 PM, Keary Suska wrote:
> 
>> Any special handling of NSTask aside, Mac OS X uses Unix-based process 
>> control which closes all child processes when the parent is closed.
> 
> No, that's not true.  Where did you get that?

It has likely, as you point out, come from the entirely wrong orifice. I 
suspect I am confusing tis with system() and popen() calls, which I think have 
a dependency on the parent process' life, but I could be wrong about that too.

> Processes with a controlling terminal get a SIGHUP when that terminal is 
> closed, and that will kill a naive process, but that wouldn't apply to 
> subprocesses of GUI apps.  Other than that, child processes are independent 
> of their parent process.
> 
>> Since your sub-program is Java you may be able to detach the child process.
> 
> This doesn't make sense to me.  What does being Java have to do with anything?

I meant as opposed to a Cocoa-based app. The Java runtime, AFAIK, does not have 
the same restrictions.

>> This is usually accomplished by the sub-program by executing a low-level 
>> fork(). It may need to be followed by an exec() to fully detach the process.
> 
> Fork() creates the child subprocess as a near duplicate of the parent.  
> Exec() replaces the process's image with a new one.  This is the standard 
> means of creating a subprocess running a new program, but doesn't 
> particularly "detach" an already-existing subprocess from its parent 
> (whatever that might mean).

Again, this might be my mistaking daemonizing pipe-to-subprocess, but I could 
be wrong about that too. 

>> Note that you can't do this with Cocoa/Objective-C (at least Apple says you 
>> shouldn't…)
> 
> You can fork() and exec() just fine.  What you can't do is fork(), _not_ call 
> exec(), and then do anything other than call POSIX async-cancel-safe APIs.  
> That includes using high-level frameworks like Cocoa, Core Foundation, or the 
> like.

This might also be where I recalled the necessity of fork-exec, but it has been 
some time since I wandered down that rabbit hole..

Sorry for the noise...

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: NSTask terminates when NSApplication exits

2012-01-18 Thread Keary Suska
On Jan 18, 2012, at 11:59 AM, Andrew wrote:

> I am trying to write a program that maintains different installs of
> another program including launching the program. To do so, I am using
> NSTask. Now when I quit my cocoa app. the NSTask app dies. The task
> that the NSTask is running is a Java program, not sure if that makes a
> difference. According to what I have read, the application should keep
> running even when the parent task exits. I am running my cocoa app
> from in XCode4, not sure if that has any effect on it. Could it be
> that I am not specifying standard* streams so when the parent app
> quits, those streams are closed and thus the process?
> 
> I can probably find out the answer by trying different things, but I'd
> like to get a better insight for what is going on and why the child
> task is terminating.

Any special handling of NSTask aside, Mac OS X uses Unix-based process control 
which closes all child processes when the parent is closed. Since your 
sub-program is Java you may be able to detach the child process. This is 
usually accomplished by the sub-program by executing a low-level fork(). It may 
need to be followed by an exec() to fully detach the process. Note that you 
can't do this with Cocoa/Objective-C (at least Apple says you shouldn't…)

Alternatively (and probably preferably) you could use launchd/Launch Services 
as recommended. Useful reading: 
http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html

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: Core Data : Correct way to force reading property from sql store?

2012-01-15 Thread Keary Suska
On Jan 14, 2012, at 2:35 PM, Jerry Krinock wrote:

> I want my app to access the new value of an object's property stored in an 
> sqlite store, after this value has been modified on disk by another process.
> 
> A few weeks ago, I did this, and I thought it was working:
> 
>   [[obj managedObjectContext] refreshObject:self
>mergeChanges:YES] ;
>   id foo = [obj foo] ;

I don't know that I have anything useful to say but the fact that you are 
trying to fault an object inside the object itself seems like a code smell. Or 
do you mean to instead do:

[[obj managedObjectContext] refreshObject: obj
   mergeChanges:YES] ;

Do you experience the same behavior if you refresh the object from a point 
outside the object, also making sure that it is not retained by anything 
outside the MOC?

> However, upon retesting today I found that foo was the old value, and after 
> puzzling over the documentation of -[NSManagedObject 
> refreshObject:mergeChanges:], and some experimentation, I fixed it by doing 
> this instead:
> 
>[[obj managedObjectContext] processPendingChanges] ;  // just in case
>NSTimeInterval oldStaleness = [[obj managedObjectContext] 
> stalenessInterval] ;
>[[obj managedObjectContext] setStalenessInterval:0.0] ;
>[[obj managedObjectContext] refreshObject:self
> mergeChanges:NO] ;
>id foo = [obj foo] ;
>[[obj managedObjectContext] setStalenessInterval:oldStaleness] ;
> 
> By the way, oldStaleness is the default value of -1.0.
> 
> Is there a better way?
> 
> It seems like "gimme the latest value of object.foo from the disk" shouldn't 
> be so hard.  If all you read is the first line of that documentation [1], you 
> think that it is easy!


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 slowing down bindings updates possible?

2012-01-13 Thread Keary Suska
On Jan 12, 2012, at 10:57 PM, Andrew wrote:

> I have a download controller with an NSMutableArray and an
> NSArrayController hooked up to a NSTableView with a view based setup.
> My array contains custom download objects. Each of those has a
> NSURLDownload instance.
> 
> Basically, I am showing a browser-download like interface with size
> downloaded, total expected size, a progress bar, time elapsed,
> download rate and estimated time left.
> 
> It is all working wonderfully, but actually too well. Right now, I am
> using will/didChangeValueForKey messages to notify observers when the
> number of bytes downloaded changes. I am doing this in the callback
> method:
> 
> - (void)download:(NSURLDownload *)download
> didReceiveDataOfLength:(NSUInteger)length
> {
>  [self willChangeValueForKey:@"bytesDownloaded"];
>  _bytesDownloaded += length;
>  [self didChangeValueForKey:@"bytesDownloaded"];
> }
> 
> The result of this is that the UI updates really frequently and the
> estimated time to complete and the download rate jump around a lot. I
> would love it if I could tell cocoa to only update the UI once per
> second instead of immediately when the property key changes.

It may well be your calculation. Do you keep a byte count array and average 
over that? This kind of approach usually smooths out jumps in data size after 
the first few.

Other than that, there isn't really anything you can do except update bytes 
only via a timer, but even that won't work all the time if you consistently 
experience data jumps. Unless you slow the timer down to a point that might be 
user-unfriendly… This approach might require a lot of trial and error to get 
right.

Anyway, all the timer callback has to do is send the willChange/DidChange, 
which doesn't sound very messy to me.

Alternatively, of course, you could use BSD sockets and control the data 
buffering to force consistency.

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 Theory Question

2011-12-28 Thread Keary Suska
On Dec 28, 2011, at 10:05 AM, Philip McIntosh wrote:

> I am just wondering about something with respect to the Model-View-Controller 
> (MVC) design pattern. Should any validation of input or output be done by the 
> model class which is handling and processing the data, or is validation more 
> properly a task to be assigned to a controller class?

I would give a qualified "yes." Usually this is the case--key-value validation 
exists for this purpose. Now, it is common to use formatters for validation as 
well, which doesn't violate MVC.

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 disable clicking parent menu item without disabling it?

2011-12-26 Thread Keary Suska
On Dec 26, 2011, at 8:39 AM, Dany Golubitsky wrote:

> I want to disable some of parent top menu links with sub-menus, so that when 
> I click at the root top nothing should happen until I navigate and click to 
> its sub menus for specific action.
> 
> For example, In Cocoa, if I have menu File -> Recent -> "...Recent files 
> list" , I can press "Recent". I want to prevent pressing "Recent". Can I 
> do it?

I don't know if I understand you correctly but any menu item without a 
target/action will do nothing when clicked, unless it has a sub-menu in which 
case it reveals its submenu.

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 get the phone number use ios sdk in iphone.

2011-12-22 Thread Keary Suska

On Dec 22, 2011, at 8:37 AM, 吴明 wrote:

> 1. [[NSUserDefaults standardUserDefaults] 
> stringForKey:@"SBFormattedPhoneNumber"];
> 
> 2. Use CTSettingCopyMyPhoneNumber();
> This function is included in Coretelephony framework.
> 
> 3. Get all contacts phone number by addressbook framework. Then get the phone 
> number. 


How you should get the number is by asking the user for it. Items #1 and #2 may 
get your app rejected. In fact, #1 is known to cause almost definite app 
rejection. #3 is error prone but if you ask the user to confirm that may be 
acceptable. Also make sure you scour the developer agreement about how you need 
to ask for this kind of information and how you use it. Misuse could get you 
permanently banned.

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: KVO Setting a flag for any property change

2011-12-14 Thread Keary Suska
On Dec 14, 2011, at 3:21 PM, Andre Masse wrote:

> 
> Clever! Thanks for the suggestion.

You probably figured this out but for prosperity there needs to be an observer 
of hasBeenModified, or the object itself can observe "hasBeenModified" and set 
the flag itself. Just a piece that might not be obvious to some...

> Andre Masse
>> Keary Suska <mailto:cocoa-...@esoteritech.com>
>> December 14, 2011 10:56
>> 
>> 
>> This kind of approach is probably best unless you can base your superclass 
>> on NSManagedObject, which does this automatically. But, as you find, there 
>> is some difficulty. I would have a pseudo-flag, say "hasBeenModified", and 
>> implement +keyPathsForValuesAffectingHasBeenModified:. In -hasBeenModified 
>> simply set the flag KVO-compliantly. You mat want to check the flag to avoid 
>> unnecessary KVO calls.
>> 
>> HTH.
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
>> 
>> Andre Masse <mailto:andre.ma...@videotron.ca>
>> December 14, 2011 08:29
>> Hi,
>> 
>> I have a superclass which has a "modified" BOOL property and a bunch of 
>> subclasses based on it. When any property is changed, I need to set this 
>> flag to YES. I can either write a setter for all properties and set this 
>> flag there, or observe all properties and set the flag in 
>> -observeValueForKeyPath. Both approach involve a lot of boilerplate coding 
>> (some subclasses have 20+ properties).
>> 
>> I thought about using -keyPathsForValuesAffectingModified: but I don't see 
>> how I can set a flag using this.


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: predicates and sort descriptors for NSFetchRequest - documentation is a bit vague

2011-12-14 Thread Keary Suska
On Dec 14, 2011, at 11:07 AM, Dave Reed wrote:

> Here's my sorting scenario with a few more details.
> 
> Entity A (the one I'm fetching) has a to-one relation to Entity B with 
> attribute b. Let's call the relation "tob" so my sort descriptor said 
> withKey:@"tob.b" and it results of the fetch request did not come back in 
> that order, but if I then sort the resulting array using the sort descriptor, 
> it does sort it.
> 
> The way I read the documentation, that should work during the fetch, but it 
> doesn't. 

Unfortunately, Core Data-Specific sort descriptor docs are fairly lacking. As I 
mentioned it may be that NSSortDescriptor doesn't translate key paths like 
NSPredicate might. It may expect them to be appropriate to a SQL query. 
Considering that the attribute b or entity B is unambiguous (i.e. entity A does 
not have an attribute with the same name), have you tried passing just "b" as 
the key? Another option is passing "B.b" as the key.

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: predicates and sort descriptors for NSFetchRequest - documentation is a bit vague

2011-12-14 Thread Keary Suska
On Dec 14, 2011, at 9:46 AM, davel...@mac.com wrote:

> 
> I have a fetch request with sort descriptors that was sorting on a many-one 
> relationship (i.e., I'm fetching Entity A which has a relationship to one 
> entity B and I was trying to get back the array of A entities sorted on an 
> attribute of B). This doesn't work using sort descriptors; however, if I 
> apply the sort descriptor to the resulting array, it does work.

I will assume you are using a sqlite store--otherwise these issues shouldn't 
apply…

> The "if you execute a fetch directly, you should typically not add 
> Objective-C-based predicates or sort descriptors to the fetch request." 
> bothers me as I see lots of examples where they are used in books on Core 
> Data.

The key phrase here is "Objective-C-based." I believe the documentation is 
making a distinction between the full functionality of NSPredicate and 
NSSortDescriptor as executed in an Objective-C context versus the subset of of 
this functionality that Core data can translate into a SQL query as described 
in the doc section "Store Types and Behaviors."

> Can someone please elaborate on what kinds of predicates and sort descriptors 
> you can use when executing an NSFetchRequest using the NSManagedObjectContext 
> method: executeFetchRequest:error: ?

The docs give guidelines, and there is a little more in the Predicate 
Programming Guide here: 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Predicates/Articles/pBasics.html#//apple_ref/doc/uid/TP40001792-SW3
 but generally speaking most predicate syntax is acceptable except for any that 
use any Cocoa method or Objective-C syntax, such as key paths that don't map 
directly to the managed object model.

If you find specific situations where predicates don't work that probably 
should due to these guidelines you should file a radar.

The sort descriptor issue may be how you are specifying the descriptor. It may 
look at key paths differently, so you may need to experiment with different 
keys (think SQL rather than KVC).

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: KVO Setting a flag for any property change

2011-12-14 Thread Keary Suska
On Dec 14, 2011, at 6:29 AM, Andre Masse wrote:

> I have a superclass which has a "modified" BOOL property and a bunch of 
> subclasses based on it. When any property is changed, I need to set this flag 
> to YES. I can either write a setter for all properties and set this flag 
> there, or observe all properties and set the flag in -observeValueForKeyPath. 
> Both approach involve a lot of boilerplate coding (some subclasses have 20+ 
> properties).
> 
> I thought about using -keyPathsForValuesAffectingModified: but I don't see 
> how I can set a flag using this.


This kind of approach is probably best unless you can base your superclass on 
NSManagedObject, which does this automatically. But, as you find, there is some 
difficulty. I would have a pseudo-flag, say "hasBeenModified", and implement 
+keyPathsForValuesAffectingHasBeenModified:. In -hasBeenModified simply set the 
flag KVO-compliantly. You mat want to check the flag to avoid unnecessary KVO 
calls.

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: Business as usual: Flipped context causing grief

2011-12-12 Thread Keary Suska
On Dec 12, 2011, at 6:07 PM, Graham Cox wrote:

> 
> On 13/12/2011, at 12:00 PM, Keary Suska wrote:
> 
>> IIRC, NSLayoutManager expects that the view it is drawing in is flipped
> 
> It expects the CONTEXT it is drawing into is flipped, and in order to do that 
> it asks the CONTEXT the value of -isFlipped.
> 
> If the context is associated with a view, the view is queried.
> 
> I don't have a view, I have a context. I create the context from a bitmap rep 
> (I'm rendering text, and other things, into an offscreen image). When you do 
> that, it assumes that the context/bitmap is not flipped, and -isFlipped 
> returns NO. There is no way I can see to return YES from isFlipped, or pass 
> setFlipped:YES to the context, or set the flippedness to YES when the context 
> is created.
> 
> That is the problem I have.


Sorry I missed the specific approach. The docs say for NSGraphicsContext 
-isFlipped:

"The state is determined by sending isFlipped to the receiver’s view that has 
focus. If no view has focus, returns NO unless the receiver is instantiated 
usinggraphicsContextWithGraphicsPort:flipped: specifying YES as the flipped 
parameter."

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: Business as usual: Flipped context causing grief

2011-12-12 Thread Keary Suska
On Dec 12, 2011, at 4:04 PM, Graham Cox wrote:

> I'm drawing objects into a bitmap rep and a context created from it.
> 
> The y axis extends downwards (i.e. it's flipped).
> 
> Normal objects render correctly.
> 
> Text is inverted.
> 
> 
> 
> This problem keeps rearing its ugly head. I'm still not sure I really 
> understand it.
> 
> When I set up the context from the bitmap, I create a transform that flips 
> the context. Paths and so forth appear the right way up. I'm rendering text 
> using the built-in text rendering engine (NSLayoutManager) and it fails to 
> notice that the context is flipped, so it appears to add its own flipping 
> transform and so text is inverted. I need to let the context I create from 
> the bitmap know that it is flipped, but there is no -setFlipped: method on 
> NSGraphicsContext, and the method that creates a context from a bitmap 
> doesn't let me pass the flippedness, as the method for creating a context 
> from a graphicsPort does.
> 
> How do I inform the context that it is flipped, so that text is rendered 
> correctly?

IIRC, NSLayoutManager expects that the view it is drawing in is flipped 
(-isFlipped returns YES). If it isn't, it will draw text inverted. S.. I 
think all you need is to implement isFlipped returning YES.

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 Display Images in a WebView

2011-12-02 Thread Keary Suska
On Dec 1, 2011, at 6:25 PM, Sandeep Mohan Bhandarkar wrote:

> Hi All,
> 
> Can some one provide any pointers as to how we can display an Image in a 
> WebView. and can this be done without the use of a HTML File.?


Have you tried to simply pass the WebView a file:// request URL to the image? 
If the image is in memory, you can use 
-loadData:MIMEType:textEncodingName:baseURL: on the WebView's main frame.

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 force WebView to use a separate NSHTTPCookieStorage ?

2011-12-01 Thread Keary Suska
On Nov 30, 2011, at 9:23 AM, Ben wrote:

> On 30 Nov 2011, at 15:22, Keary Suska wrote:
> 
>> On Nov 30, 2011, at 7:48 AM, Ben wrote:
>> 
>>> On 30 Nov 2011, at 14:24, John Joyce wrote:
>>> 
>>>> On Nov 30, 2011, at 8:11 AM, Mike Abdullah wrote:
>>>> 
>>>>> On 30 Nov 2011, at 12:00, Ben wrote:
>>>>> 
>>>>>> I am writing an app which opens up multiple WebView's of the same web 
>>>>>> site. The problem I'm having is that the website detects that I already 
>>>>>> have a page open and closes the previously opened page. 
>>>>>> 
>>>>>> So I'm presuming that the method by which it is detecting identical 
>>>>>> pages is via cookies, and if I can make each WebView use a separate 
>>>>>> NSHTTPCookieStorage rather than the normal shared singleton, I think I 
>>>>>> might solve the problem. 
>>> 
>>> Sure, well I have ruled out that the site is using IP and hostName, and as 
>>> far as my knowledge of Javascript goes, I don't think  javascript running 
>>> on one web page, can access a separate web page unless it created it 
>>> itself. That's all the methods I can think of that they may be using .
>> 
>> JavaScripts may effect any page whose URL shares the same domain, in 
>> essence. So a JavaScript on a site page could detect whether a page has been 
>> previously loaded and close it. I would say that it is unlikely a cookie 
>> issue as the JavaScript approach is easier and less error prone.
>> 
>> You may also want to consider *why* the site is doing this. They may be 
>> using window names or id's that must be unique for the site to function 
>> properly, and circumventing it could cause unexpected issues.
> 
> Oh OK, well that put's an entirely different perspective on things. I did not 
> know that same domain pages could communicate. 

> So if I were to hunt down the culprit javascript I could perhaps disable it 
> with something like…
> [windowController.webview 
> stringByEvaluatingJavaScriptFromString:@"location.hostname=null;"];

This approach may not work as it depends on how and when the browser performs 
its security checks. If I were to hazard a guess I would think that this 
approach would not work as it could be a security hole. As long as you can 
determine the method used to close the window you can manipulate the DOM to 
prevent it. I.e., at some point a script is deriving the window object. Figure 
out how and you can prevent it. But also keep in mind my previous caveat--doing 
so could cause the site to not function properly.

> Thanks. Oh the reason I want this functionality is that I have multiple 
> accounts for dealing shares, every day I have to set up 3 different browsers 
> and 10 or so different pages and it takes 10 minutes of my life every day. So 
> I'm trying to find a way to do everything I need, open every page and account 
> in 1 click.


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 force WebView to use a separate NSHTTPCookieStorage ?

2011-11-30 Thread Keary Suska
On Nov 30, 2011, at 7:48 AM, Ben wrote:

> 
> On 30 Nov 2011, at 14:24, John Joyce wrote:
> 
>> 
>> On Nov 30, 2011, at 8:11 AM, Mike Abdullah wrote:
>> 
>>> 
>>> On 30 Nov 2011, at 12:00, Ben wrote:
>>> 
>>>> I am writing an app which opens up multiple WebView's of the same web 
>>>> site. The problem I'm having is that the website detects that I already 
>>>> have a page open and closes the previously opened page. 
>>>> 
>>>> So I'm presuming that the method by which it is detecting identical pages 
>>>> is via cookies, and if I can make each WebView use a separate 
>>>> NSHTTPCookieStorage rather than the normal shared singleton, I think I 
>>>> might solve the problem. 
> 
> 
> Sure, well I have ruled out that the site is using IP and hostName, and as 
> far as my knowledge of Javascript goes, I don't think  javascript running on 
> one web page, can access a separate web page unless it created it itself. 
> That's all the methods I can think of that they may be using .

JavaScripts may effect any page whose URL shares the same domain, in essence. 
So a JavaScript on a site page could detect whether a page has been previously 
loaded and close it. I would say that it is unlikely a cookie issue as the 
JavaScript approach is easier and less error prone.

You may also want to consider *why* the site is doing this. They may be using 
window names or id's that must be unique for the site to function properly, and 
circumventing it could cause unexpected issues.

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 highlight the current line in NSTextView?

2011-11-06 Thread Keary Suska

On Nov 6, 2011, at 8:39 AM, Nick wrote:

> Keary, Douglas
> Could you please give me a hint what methods to search for?
> Basically I need an NSRange of the current line (or that part of it, whereb 
> the cursor is in, if the line is word-wrapped). Then I'll simply change this 
> substring's attributes.
> Should i find the current text cursor's position (location) in text, and keep 
> invoking locationForGlyphAtIndex for every previous symbol to this cursor 
> location, up till I get the smallest value?
> What's the right way here?

This is all theory, and I have not had to do this, but if it were me I would 
look at the methods with the words "lineFragment" in them will help isolate the 
line. I imagine that once you get the glyph nearest the insertion point, you 
should then be able to use lineFragmentUsedRectForGlyphAtIndex:effectiveRange: 
and passing its return value to -setSelectedRange:. That should at least get 
you close if it doesn't do the trick. Also, if you didn't notice from another 
responder, you can get the appropriate NSLayoutManager from the NSTextView 
itself.

HTH,

> 2011/11/4 Keary Suska 
> On Nov 4, 2011, at 7:19 AM, Nick wrote:
> 
> > Hello
> > Basically the question is about getting the NSRange of the line of
> > NSTextView where the text input cursor is currently in.
> > Word wraps are considered as legal 'new lines' - only one line should
> > actually be highlighted.
> >
> > How could I do this (get an NSRange of a single line)?
> 
> Cocoa's text handling system is a bit complex (you should read the 
> text-handling guide) but it shouldn't be too difficult. The object you 
> probably need to talk to is the appropriate NSLayoutManager (probably just 
> one) which belongs to the NSTextStorage of the NSTextView (whew!). That 
> should get you started.


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: 2nd table array linked to 1st table selection, updating

2011-10-21 Thread Keary Suska
On Oct 21, 2011, at 10:16 AM, Chris Paveglio wrote:

> My app watches several folders (and subfolders) on our file servers, and 
> counts and displays the files in those folders.
> I have a class for the folder data that contains the count from 3 subfolders 
> (ints) and then an array of file names of the files from one of the 
> subfolders.
> There are 8 folders that are watched, and those 8 items are in an array. I 
> have a table view that has columns for the integer values from the class 
> object. Then there is a second table where I show the file names when the 
> user selects a row from the first table.
> I have both these tables set up using bindings and array controllers. The 
> first table is straight forward setup. The second one's content array is 
> bound to the first array controller. The controller key is "selection" and 
> the model key path is the name of the array in the class object.
> The second table shows up fine, and it's content changes when I change the 
> selection on my first table.
> But when the contents of the folder changes and the app recalculates the 
> data, I get an error that *** -[NSCFArray objectAtIndex:]: index (3) beyond 
> bounds (3)
> This only occurs when the first table has a selection, and I understand 
> (probably) that it's because the second table is based on the first, and that 
> the data for the 2nd table is changing in a non-KVC compliant kind of way. 
> I'm not telling the 2nd array controller to remove or reset the values in the 
> class object's array, I am just directly removing all the objects from class 
> object array, then re-adding the newly scanned file names into the array.
> My workaround is, in code, the first table is deselected, the values are all 
> updated, and then the originally selected row is reselected. This makes the 
> display function and update properly.

As you think, you need to update the "primary" array in a KVC/KVO compliant 
way. That is always the  best way to update objects that are observed/bound. 
The simplest way is to first get the mutable proxy using -[object 
mutableArrayValueForKey:]. Any changes you make to the returned array will be 
propagated appropriately.

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: Prevent table sorting

2011-10-21 Thread Keary Suska
On Oct 21, 2011, at 9:19 AM, Chris Paveglio wrote:

> I have a tableview, that's populated via bindings to an array controller. Is 
> there a way to prevent selecting the table column headers, so that the 
> content can't be rearranged at all? I've looked through everything in IB for 
> the array controller, the table, its columns, etc and don't see a box to 
> prevent/allow selection reordering. I could hide the table headers and make 
> my own text labels, but I thought there'd be a simple on/off checkbox for 
> this.

It's in the column value binding. Look for "Creates Sort Descriptor".

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: Custom NSArrayController that manages its own array?

2011-10-18 Thread Keary Suska
On Oct 18, 2011, at 5:16 PM, Jens Alfke wrote:

> 
> On Oct 18, 2011, at 11:59 AM, Keary Suska wrote:
> 
>> In your subclass you could use the machinery afforded by 
>> automaticallyPreparesContent, or simply set the content on awakeFromNib or 
>> whenever it is needed.
> 
> Hm. So in other words I would implement the KVC methods in the subclass 
> (-countOfEntries, etc.), then implement
>   - (void)prepareContent {
>   self.content = [self valueForKey: @“entries”];
>   }
> to get the fake NSMutableArray and set it as the controller’s content. I 
> guess that would work.

Well, "entries" in this case is redundant. If you subclass is designed to 
manage an array of "entries", then its content would simply be the array 
itself. There is no need to abstract it out by the key. In fact, it is a code 
smell to do so.

When dealing with collections even the best of us forget that in the MVC 
approach the model for the NSArrayController is the array itself, and not the 
object that contains it. The key and the collection KVC methods are simply a 
way to acquire the model object from another object that has a relationship to 
it. Therefore, in this case, the content of the object controller is the 
reference to the model.

It may be useful to mention that there are limitations to how 
NSObjectControllers and their subclasses respond to KVO, such that if any 
object needs direct access to the array's objects you may want to consider 
having the array owned by some other object. In particular, 
+keyPathsForValuesEffectingKey, which fails to function for key paths through 
NSObjectControllers. This might be the basis of Quincy's flat out "don't do it" 
recommendation. But for most simple, bindings-only approaches, the above 
approach will work fine.

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: Custom NSArrayController that manages its own array?

2011-10-18 Thread Keary Suska
On Oct 18, 2011, at 11:44 AM, Jens Alfke wrote:

> To help bind my data model to AppKit tables, I’ve written a custom class that 
> implements KVC collection accessors to define a mutable-array property. That 
> is, it implements methods like -countOfEntries, objectInEntriesAtIndex:, 
> insertObject:inEntriesAtIndex, etc. I can then bind this as the contentArray 
> property of an NSArrayController, and use that controller to drive a table 
> view and master-detail UI.
> 
> I’d like to avoid using a separate class, though (so I can make this setup 
> more easily reusable.) Is it feasible to subclass NSArrayController and put 
> the collection access methods in the subclass? Then I’d just have an 
> “EntryArrayController” class I could drop into my nib. From the docs I can’t 
> figure out whether this is an appropriate thing to do.

There is no reason that an NSArrayController cannot manage its own content (in 
fact it is coded to do so), but the idea that the content would be "keyed" is 
odd, as there generally isn't any need to. I.e., the array controller would not 
bind to itself, and if any other array controller wants its content it can 
simply bind to arrangedObjects. So the whole collection KVC stuff is 
unnecessary.

In your subclass you could use the machinery afforded by 
automaticallyPreparesContent, or simply set the content on awakeFromNib or 
whenever it is needed.

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: NSArrayController Update Delay

2011-10-13 Thread Keary Suska
On Oct 13, 2011, at 2:20 PM, Richard Somers wrote:

> Consider a NSArrayController in entity mode. When a managed object is 
> inserted into the managed object context the controller's arrangedObjects 
> property is not updated immediately.

How is this happening? Via code? or Via the NSArrayController (add: or 
insert:)? In the latter case the docs say, "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."

> Calling a controller 'fetch:' immediately after inserting the managed object 
> into the managed object context does not help. The controller's 
> arrangedObjects property is still not updated.
> 
> Perhaps there is a KVO change notification delay between the time when the 
> managed object is inserted into the managed object context and the time when 
> the controller finds out about the change.

Not in my experience (except as noted above).

> Does anyone have any insight into what is going or how to force the 
> NSArrayController's arrangedObjects property to update?

If the action has been deferred as described above, you are mostly out of luck. 
You could chance manually turning the runloop but it is fragile and generally 
recommended against.

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: NSArrayController Selection and Managed Object Context Undo

2011-10-06 Thread Keary Suska
On Oct 6, 2011, at 1:14 AM, Richard Somers wrote:

> It is very common for Applications to update the selection during undo 
> operations.
> 
> By default NSArrayController automatically selects objects as they are 
> inserted. This works if objects are added using one of the controller's add 
> or insert methods. If objects are added directly to the controller content 
> object using other means then this mechanism does not work.
> 
> Take for example a NSArrayController with a managed object context for the 
> content. If one or more objects are added to managed object context as the 
> result of an undo, the controller's selection does not change or update.
> 
> Is there an easy way to set the controller's selection when an undo operation 
> adds objects back into a managed object context?

AFAIK you will need to manage selection restoration semantics yourself, and it 
may not be easy and it may be fragile. Note also that the preserve and avoid 
empty selection settings will also have an effect. That being said, the 
approach would be--before adding/deleting outside the controller--to grab the 
managed object context's undo manager, open an undo group, add selection 
restoration operations, perform the operation, then close the group. This 
should cause the undo to restore selection. Of course, this is theory, as I 
haven't had to actually do it, and more experienced Core Data wranglers may 
have more to add.

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: combining two entities to one binding

2011-10-02 Thread Keary Suska
On Oct 2, 2011, at 6:05 AM, Koen van der Drift wrote:

> On Oct 1, 2011, at 3:09 PM, Keary Suska wrote:
> 
>> Not specifically for NSTextView. Text fields have the "value with pattern" 
>> bindings, but no such luck for text views. In such cases I generally have a 
>> "dynamic" property of a model object that consists of a pseudo-getter and 
>> +keyPathsForValuesAffectingKey.
> 
> It actually is a label, so I can use the value with pattern bindings, thanks 
> for pointing that out.
> 
> Any idea how to get a hard return between the two values?
> 
> %{value1}@  %{value2}@

Unfortunately not in the binding text itself, at least AFAIK. There are a 
number of ways to do this, the most obvious being adding a method to your model 
class such as:

- (NSString *)hardReturn
{
return @"\n";
}

and adding it to your bind pattern. I have to say though, that this begs for a 
dynamic property as I describe above. It is much more extensible and easier to 
debug.

If, however, you find that you will need to insert carriage returns in a number 
of different bindings for a number of different model objects, you might 
consider using an NSFormatter that, for example, replaces occurrences of the 
string "\n" with a newline. You could also set a category on NSController for 
the method above, and have it available for any binding. Many options.

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: combining two entities to one binding

2011-10-01 Thread Keary Suska
On Oct 1, 2011, at 11:54 AM, Koen van der Drift wrote:

> In my core data model, I have several string properties that I would like to 
> bind to one NSTextView. So, I would like the text view to show both the name 
> and description entities as if they were one string.
> 
> Is there a way to do this, in IB I can only bind one at the time (I think).

Not specifically for NSTextView. Text fields have the "value with pattern" 
bindings, but no such luck for text views. In such cases I generally have a 
"dynamic" property of a model object that consists of a pseudo-getter and 
+keyPathsForValuesAffectingKey.

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: controller question

2011-09-27 Thread Keary Suska
On Sep 26, 2011, at 9:22 PM, Quincey Morris wrote:

> On Sep 26, 2011, at 19:03 , Ariel Feinerman wrote:
> 
>> if I use persistence NSMutableArray as content array in NSArrayController so
>> [arrayController setContent: m_array]; will controller copy one or retain?
> 
> The array controller will *observe* the array, not copy it.

I will take your word for how the controller is internally managing its content 
as I haven't inspected it, but although it is true that the controller should 
not copy the object (otherwise the docs should require that the content object 
conform to NSCopying), how the controller content is internally managed is not 
documented and shouldn't be relied on. Setting content is the same as setting 
any object property, and how the object is managed is no business of the setter.

>> So every deletion or addition in the controller will come back to origin.
> 
> Yes.

Again, this isn't guaranteed since it relies to how the controller may be 
managing its content.

>> Or we must synchronize one or get from controller to write to url?
> 
> No, you don't have to either of those things.
> 
> However, if you modify the array directly, you have to do it KVO compliantly, 
> or the array controller won't see the change.

Again, same issue. When not using bindings, you shouldn't rely on the behavior, 
even if it happens to work (for now)...

In sum, if you want synchronization without glue code, use bindings. If you 
don't need to manage the array outside of the controller you can retrieve the 
array contents when you need it as well...

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: NSArrayController and NSTableView

2011-09-19 Thread Keary Suska
On Sep 19, 2011, at 6:00 PM, R wrote:

> I find that in order for my NSTableView to update when bound to an
> NSArrayController, I have to add objects to the array vis the
> NSArrayController.  This works great if the window, tableview, and
> arraycontroller are all part of the same class.
> 
> Question:
> 
> Can I have a tableView in one class, bound to an arraycontroller in a
> different class.  I would prefer to keep my arraycontroller in the
> same class as my array, but have need to put a tableview on views
> associated with another class.

You will need to sort out your nomenclature--all of the objects you refer to 
are different classes, and you are probably not using a "contains" model, so 
none of ther objects in quesiton are likely "contained". Do you mean 
"reference"? Or "nib file"? Certainly, what you are attempting works best when 
all objects are in the same nib, but there is nothing inherent in any of them 
that they would need to have references from the same class. In any case, 
bindings take care of themselves and shouldn't need any trigger to work, which 
is a red flag that your existing approach is broken. We will need more 
information using proper language to even understand the question...

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: Windows and views and controls, oh my!

2011-09-05 Thread Keary Suska
On Sep 5, 2011, at 9:32 AM, William Squires wrote:

> Okay, I'm having a tizzy here. Most of the '...learn MacOS X...' programming 
> books gloss over the nitty-gritty of actually creating and displaying various 
> windows, either assuming they're going to be document windows (as part of a 
> document-based app), or they're just there as part of an example of some 
> other topic.


> While I can create the UI easily enough in IB, what I don't understand is how 
> to actually load, instantiate, and display the window from my view controller 
> object.
> I realize the view controller has to load the nib, but how do I:
> 
> 1) make sure the window isn't displayed until all it's views (controls) have 
> had a chance to initialize their default (visual) state properly
> 2) actually display the window, either modally, or not.
> 3) if modal, how does my client code make sure it doesn't return from the 
> operation until the user closes the window (by clicking the close box, or by 
> dismissing it in code from an IBAction tied to an NSButton whose caption is 
> "Done" or some such.)
> 4) Pass information to/from the client code and the view controller?
> 5) Prevent the window from closing (if non-modal) if the contents are 'dirty'?
> 
> I prefer to actually make each window and its view controller as a pair, 
> rather than rely on the provided window in MainWindow.xib; this way I'll have 
> to actually know how to tie a .xib and a view controller together, rather 
> than rely on whatever may be in the provided MainWindow.xib in the blank 
> project

Read the "Window Programming Guide" in the API docs (I don't have a web link 
but Xcode will get you to the right place). It pretty much answers all your 
questions.

It sounds like you are coming from iOS development--forget what you know about 
view controllers. The Mac OS X equivalent (NSViewController) is another animal 
altogether. Specific to your question you are interested in 
NSWindowControllers. There is also no root controller class such as in iOS.

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: Core Data to many relationship deletion causing exception

2011-08-16 Thread Keary Suska
On Aug 16, 2011, at 12:18 PM, Andrew Kinnie wrote:

> I have an iOS 4 + app, which is now being retrofitted to use Core Data.  I 
> have an Entity "Article" which has a to-many relationship to another Entity 
> "MediaResource" and I generated NSManagedObject subclasses for each.  The 
> relationship is called "media" and is set to be optional, and to Cascade 
> delete the associated MediaResource objects.  There is an inverse to-one back 
> to the Article (with a delete rule of nullify).
> 
> The generated code included a property of type NSSet * media in the Article 
> class, as well as (among others) these methods:

Who generated the code? Xcode? Or Something else? Either there is a bug in the 
generated code or the code is expecting you provide mutable backing for the 
declared property. I would file a bug anyway as the code should generate those 
methods as well. 

> - (void)addMediaObject:(MediaResource *)value {
>NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
>[self willChangeValueForKey:@"media" 
> withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
>[[self primitiveValueForKey:@"media"] addObject:value];
>[self didChangeValueForKey:@"media" 
> withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
>[changedObjects release];
> }
> 
> - (void)removeMediaObject:(MediaResource *)value {
>NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
>[self willChangeValueForKey:@"media" 
> withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
>[[self primitiveValueForKey:@"media"] removeObject:value];
>[self didChangeValueForKey:@"media" 
> withSetMutation:NSKeyValueMinusSetMutation usingObjects:changedObjects];
>[changedObjects release];
> }
> 
> There are no NSMutableSets here anywhere, but I assume the auto-generated 
> code knows what it is doing.   I can add an article, then add a MediaResource 
> object to it, and do it like this:

Clearly, not a safe assumption, or at least it isn't safe to assume that you 
have provided the "generator" of the code enough information to generate proper 
code. Either could be true, so the best bet is to always understand exactly 
what any code is doing. Or, as you see, you won't be able to debug it.

In short, you either need to implement a mutable ivar-backed primitive value or 
use different methods for manipulating your sets.

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: Strange NSZombie occurring

2011-08-07 Thread Keary Suska
On Aug 7, 2011, at 7:10 AM, Scott Steinman wrote:

> I've got a zombie appearing in the weirdest place in my program.  Here is the 
> relevant part of the code, using generic names for the methods:
> 

First off, this isn;t a zombie issue. Zombies are objects that haven't died 
though they should have. Also called leaks.

Anyway, have you stepped through the code to make sure your array is being 
constructed properly at all?

> -(NSArray *)wordsInPhrase:(NSString *)thePhrase
> {
>   NSArray *wordArray;
> 
>   [wordArray arrayByAddingObjectsFromArray:[phrase 
> componentsSeparatedByString:@" "]];
>   numWords = [wordArray count];
>   return wordArray;
> }

> Now, the strangeness: words exists and is OK in setUpDisplay and startDisplay 
> in that it contains the right words from the phrase.  But in changeWords:, 
> somehow words is nil.  I'm at a loss to figure out how words could be 
> released between start and changeWords:.  I'd appreciate some help.

How do you know this? based on your code this statement cannot be the case. 
Debugger is your friend...

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: CoreData "I/O error for database: no such table"

2011-08-05 Thread Keary Suska
On Aug 4, 2011, at 2:30 PM, Nick Zitzmann wrote:

> I tried searching around and found one other person who had the same 
> problem[1], but no one followed up with a good solution for existing 
> databases.
> 
> I have an entity with a many-to-many relationship to itself, called "parents" 
> and "children". And when I take a database that was made by an application 
> built by Xcode 3.2.6 and move that application to Xcode 4.1, I'm now getting 
> this error when trying to look up something in that entity:
> 
> I/O error for database at /path/to/mydatabase.db.  SQLite error code:1, 'no 
> such table: Z_16PARENTS'
> 
> It looks like the model compiler made a subtle change to the many-to-many 
> table that is part of the model used to make the database during the switch. 
> How do I make it so that it uses the same tables that it used to use? 
> Throwing out and rebuilding the existing database is not an option.
> 
> I already tried changing the Mac OS X deployment target, since I noticed that 
> the deployment target is passed to momc, but that did not make any difference.
> 
> I was able to work around the problem by creating a custom build rule that 
> builds the data model using Xcode 3's momc tool instead of Xcode 4's tool, 
> and while that did solve the problem, there has got to be a better way. But 
> what is that way? I can't believe Xcode 4 would ship with such a regression 
> in momc...
> 

Depending on the number of differences you could simply fire up the sqlite 
client and rename the tables in the database to what the new model compiler 
generates.

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: Question about sending to PHP from Obj-C

2011-08-04 Thread Keary Suska
On Aug 4, 2011, at 7:52 AM, Eric E. Dolecki wrote:

> I have a little script sitting locally on my Mac (webserver).
> 
> http://eric.domain.com/iOS_Log/logger.php:
> 
>  $myFile = "yabba.txt";
> $fh = fopen($myFile,'a') or die("can't open file");
> $query = $_GET["string"];
> $stringData = $query."\n";
> fwrite($fh,$stringData);
> fclose($fh);
> ?>

Just a note that it is not useful to post the PHP code--not only is it not 
relevant to your case, there is no guarantee that list members are familiar 
enough with PHP to make real sense of it.

> I am simply trying to send the PHP a small string from my app on a device.
> I've seen examples of POST everywhere, but looking for GET.
> 
> Of course if I do *http://eric.domain.com/iOS_Log/logger.php?string=Foo* in
> a browser it works fine.

Anyway--can you be more specific about your problem? Regarding specifying query 
strings, Cocoa doesn't provide any convenient means that I know of to build 
query strings so you have to manually assemble them. Something like:

NSString *urlString = [NSString 
stringWithFormat:@"http://eric.domain.com/iOS_Log/logger.php?string=%@";, [foo 
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
NSURL *url = [NSURL  URLWithString: urlString];

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: NSNumberFormatter documentation error?

2011-07-30 Thread Keary Suska
On Jul 30, 2011, at 9:09 AM, Andre Masse wrote:

> According to the NSNumberFormatter documentation:
> 
> setGeneratesDecimalNumbers:
> Controls whether the receiver creates instances of NSDecimalNumber when it 
> converts strings to number objects.
> 
> - (void)setGeneratesDecimalNumbers:(BOOL)flag
> Parameters
> flag
> YES if the receiver should generate NSDecimalNumber instances, NO if it 
> should generate NSNumber instances.
> Discussion
> The default is YES.
> 
> Dragging an NSNumberFormatter object in XCode 4.1, choosing "Mac OS X 10.4 + 
> Default" and "Decimal" in the popup menus generate the following error at 
> runtime when using values entered by the user in a tableview'cell:
> 
> -[__NSCFNumber decimalNumberByMultiplyingBy:]: unrecognized selector sent to 
> instance 0x1067f3260
> 
> You have to choose "Mac OS X 10.4 + Custom" and select the checkbox "Generate 
> Decimal Numbers". It looks like the default is "NO".
> 
> Do I misinterpret the documentation or should I file a bug on radar?

It's not a matter of misinterpretation per se. The documentation reflects the 
API, and would apply only to objects you create in your own code. Interface 
Builder may choose to have its own defaults for objects created by it, and 
those choices would not be documented by the API, but may be documented by 
IB-specific documentation. If there is no such IB-specific documentation (which 
is possible), I would only file a radar that Apple have specific documentation 
on object defaults in Interface Builder.

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: Problem in coming out of modal run loop

2011-07-25 Thread Keary Suska
On Jul 25, 2011, at 6:01 AM, Abhijeet Singh wrote:

> Hi,I am opening a NSPanel as a modal window using runModalForWindow 
> method.The problem is when i close the panel the modal run loop is not 
> stopped. I have tried all the possible ways ( stopModalWithCode, stopModal, 
> abortModal). But nothing works. I have number of modal windows in my 
> applications but all other windows work fine. Infact I am opening this 
> NSPanel from inside one of the modal window (is this a problem ?). Please 
> suggest a solution...Thanks and RegardsAbhijeetDear cocoadev ! Get Yourself a 
> cool, short @in.com Email ID now!

Calling -runModalForWindow within a modal session is usually not what you 
want--Cocoa doesn't "stack" modal sessions per se and some behavior may be 
undefined.

That being said, when are you trying to stop the modal session? In 
-windowShouldClose? That's probably the best case for your implementation, but 
I would also add that modal windows generally shouldn't have close boxes and 
should have a cancel/OK button approach instead.

Back in the game,

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 based Data Model dilemna

2011-01-27 Thread Keary Suska

On Jan 26, 2011, at 9:21 AM,  David DelMonte wrote:

> Hi all, I am trying to develop a core data model to meet a language grammar.
> 
> In this grammar, there are verbs, tenses and persons. (There are also voices 
> - but my brain cannot hear them right now:) )..
> 
> One scenario is to have the verbs and tense names in a single entity. 
> However, this would require that each tense name is bound to a specific 
> person entity. 
> 
> Another scenario is to have the Verb and Persons Entities use the tense name 
> entity only as a lookup table.

Don't know what you mean by "lookup table", but I would approach it with a 
verb, tense, and person entities, with a "linker" table. This is an RDBMS 
technique--in Core Data terms, you would have an entity without any properties 
but with to-one relationships with all three (verb, tense, person) thereby 
allowing any combination of the three to exist without having redundant data.

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: Odd Crash when adding table columns manually

2011-01-12 Thread Keary Suska
On Jan 11, 2011, at 5:49 PM, Eric Gorr wrote:

> I do release them after adding them to the table. It will still crash...

I cannot reproduce the crash with your test project. Have you verified, using 
zombies, that in fact it is a table column crashing? It might have to do with 
an invalid data source object...

> On Jan 11, 2011, at 7:29 PM, Peter Lübke  wrote:
> 
>> Table columns are retained by the table view they are added to.
>> 
>> So you can safely release or autorelease the table column right after 
>> invoking -addTableColumn: .
>> The table view owns its columns and will release them when it itself is 
>> released.
>> 
>> This is the normal behaviour when adding subviews to an NSView or its 
>> subclasses.
>> 
>> Peter
>> 
>> 
>> Am 11.01.2011 um 18:06 schrieb Eric Gorr:
>> 
>>> I've got a sample test project at:
>>> 
>>> http://ericgorr.net/cocoadev/TableColumnTest.zip
>>> 
>>> which reproduces the strange crash.
>>> 
>>> I have a NSTableView to which I need to add NSTableColumns manually using 
>>> the addTableColumn: method. The problem is that for some reason when I 
>>> release the window and everything is being deallocated, someone has an 
>>> extra retain on the table column and it sticks around. This causes a crash 
>>> because the OS tries to redraw the table which really isn't there.
>>> 
>>> Note: With the code as written, it will only cause a crash sometimes...if 
>>> you comment back in the call to the EventAvail function in 
>>> WindowTestAppDelegate.m, it will crash every time...this is how I ended up 
>>> finding the odd behavior to begin with - I am working with a cocoa/carbon 
>>> app and EventAvail is still being called.
>>> 
>>> I can avoid the crash if, in my TableController class, I manually remove 
>>> the table column from the table first. Is this what I am expected to do if 
>>> I manually add the column? I would not have thought so, but perhaps I am 
>>> wrong...?
>>> 
>>> In TableController.m, I have the function GetNewColumn which creates a new 
>>> table column. After I alloc and init the column, I can log the retain count 
>>> of the column and see that it is 1. After I call setWidth: on the table 
>>> column, I can see that the retain count is 2.
>>> 
>>> Can anyone shed some light on what might be going on here and why it is 
>>> crashing?
>>> 
>>> (if it matters, I am still running on 10.6.5)

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 with ArrayController bindings not updating?

2011-01-02 Thread Keary Suska
On Jan 1, 2011, at 5:13 PM, Ben Golding wrote:

>   Controller key  selection

This binding is wrong in your case. Refer to the examples in the Bindings 
Programming Topics document: 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaBindings/CocoaBindings.html,
 especially how table views are bound to array controllers.

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: assign property behaves differently from simple instance variable???

2010-12-14 Thread Keary Suska
On Dec 13, 2010, at 12:01 PM, Matt Neuburg wrote:

>self->firstResponder = tf;

Well, the proper syntax is self.firstResponder . Using the deference is 
probably a back-door way to access the class struct. Unless I misunderstand 
something

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: Interprocess Communication (IPC) : Which "technology" to use?

2010-12-07 Thread Keary Suska
On Dec 7, 2010, at 9:28 AM, Jerry Krinock wrote:

> My application needs to communicate with my associated Internet Plugin (a 
> bundle that runs in web browsers).  For example, here is one sequence:
> 
> • App sends a "hello" to the plugin.
> • Plugin processes "hello", responds to app, indicating that it is installed 
> and alive.
> • App sends up to a few hundred KB to the plugin.
> • Plugin sends a few tens of KB back to the app.
> 
> This may happen several times a day.
> 
> Apple documentation seems to be steering me into Distributed Objects (DO) for 
> this.  But DO are so complicated!  There are vended objects, proxies, 
> connection configurations, etc.  Looks like I'd have to study it for a week 
> or more.  Since the web browser talks in JSON-encoded strings anyhow, I don't 
> need to send any Cocoa objects; just bytes are fine.
> 
> Trying to use what I know, I've been using NSDistributedNotificationCenter to 
> send little messages, and when there is significant data, the sender writes 
> the data to a temporary file and sends the temporary file's path as userInfo 
> in the notification.  Upon receiving the notification, the receiver reads the 
> file; end of story.
> 
> This seems to work OK, except for the minor annoyance of distributed 
> notifications always arriving on the main thread and needing to be forwarded. 
>  I was thinking that maybe I should use NSPort since I've had some experience 
> with it, but NSPort documentation advises that "You should implement 
> interapplication communication using distributed objects whenever possible 
> and use NSPort objects only when necessary."  Why is that?
> 
> How should I be doing this?

If the data you are exchanging is fairly lightweight I can recommend shared 
memory segments. Decidedly un-Cocoa-like but very fast and reliable. DO is 
heavy and distributed notification are unreliable (per the documentation). In 
both cases you may need code to ensure reliability.

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: Asking an outline/table view to send it's setObjectValue:... message

2010-11-22 Thread Keary Suska
On Nov 22, 2010, at 4:09 AM, Thomas Davie wrote:

> I'm writing a custom cell at the moment that's used in an outline view, it's 
> object value changes sometimes when the outline view doesn't expect it to 
> (which seems to be only on mouse down or end editing).  Is there some way I 
> can force the outline view to send it's - (void)outlineView:(NSOutlineView 
> *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn 
> *)tableColumn byItem:(id)item message?

Have you tried reloadItem: or setNeedsDisplayInRect: ?

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: readonly property which is a mutable array

2010-11-19 Thread Keary Suska
On Nov 18, 2010, at 7:51 PM, Ken Thomases wrote:

> On Nov 18, 2010, at 9:33 AM, Keary Suska wrote:
> 
>> On Nov 18, 2010, at 5:35 AM, Remco Poelstra wrote:
>> 
>>> Hi,
>>> 
>>> I've a object like to following:
>>> @interface  {
>>> NSMutableArray *items;
>>> }
>>> @property (nonatomic,readonly) NSMutableArray *items;
>>> @end
>>> 
>>> I also have a protocol as follows:
>>> @protocol Proto
>>> @property (nonatomic,readonly) NSArray *items;
>>> @end
>>> 
>>> I of course want the items to be read only for the outside world, but the 
>>> object itself should be able to modify it. Now the compiler complains about 
>>> the properties not matching. How should I solve this? Make a custom getter 
>>> that returns an immutable array? Make the property refer to a mutable 
>>> array? Make the property an immutable array and make copies of the array 
>>> while modifying it?
>> 
>> The ivar type and the property type don't have to match. In fact, there does 
>> not need to be any ivar backing whatsoever to properties.
>> 
>> Change your property declaration to NSArray *, and implement the getter with 
>> [[array copy] autorelease] or similar.
> 
> You don't need to implement the getter.  The Cocoa docs are very clear that 
> callers must respect the declared type of properties (i.e. return type of 
> getters).  That is, if the getter is declared to return an immutable NSArray, 
> then callers must not interrogate the returned object to determine if it's 
> really mutable nor invoke mutation methods on it.  It may be, and often is 
> (even in framework classes), that such a method returns an object that is, in 
> fact, an NSMutableArray.  That's an irrelevant implementation detail.

We could say that it *should* be an implementation detail, but may lead to bugs 
if a copy isn't returned, as even Cocoa does *not* guarantee that an object 
will not be mutated out from underneath you (I include by reference the 
responses in this thread made by Jonathan and Andreas).

Case in point, get the array of table columns from an NSTableView, then while 
enumerating them remove a column from the tableview and BAM!

So, I think we should write code to guarantee immutability to the caller, 
regardless of type of course, which is the API contract you spell out. I see 
the easiest way as always returning a copy in the getter. But I don't remember 
how synthesized accessors are implemented on the back-end, so I don't know if 
they do the smart thing by default...

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: readonly property which is a mutable array

2010-11-18 Thread Keary Suska
On Nov 18, 2010, at 5:35 AM, Remco Poelstra wrote:

> Hi,
> 
> I've a object like to following:
> @interface  {
>   NSMutableArray *items;
> }
> @property (nonatomic,readonly) NSMutableArray *items;
> @end
> 
> I also have a protocol as follows:
> @protocol Proto
> @property (nonatomic,readonly) NSArray *items;
> @end
> 
> I of course want the items to be read only for the outside world, but the 
> object itself should be able to modify it. Now the compiler complains about 
> the properties not matching. How should I solve this? Make a custom getter 
> that returns an immutable array? Make the property refer to a mutable array? 
> Make the property an immutable array and make copies of the array while 
> modifying it?

The ivar type and the property type don't have to match. In fact, there does 
not need to be any ivar backing whatsoever to properties.

Change your property declaration to NSArray *, and implement the getter with 
[[array copy] autorelease] or similar.

You don't have much choice if you want a public immutable, but private mutable.

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: RTFDFromRange returns different data

2010-11-13 Thread Keary Suska
On Nov 13, 2010, at 9:50 AM, Kyle Sluder wrote:

> You really shouldn't be using NSKeyedArchiver for persisting data out
> to disk, anyway. What happens if you try to load the data on an older
> version of the OS?

This statement as I understand it is contrary to the documentation, as well as 
some implied API contracts with regards to data serialization, to whit: 
file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/index.html#documentation/Cocoa/Conceptual/Archiving/Articles/compatibility.html%23//apple_ref/doc/uid/20001055-BCICFFGE

Unless there is something else you are referring to...

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: Irregular layout of radio buttons

2010-11-08 Thread Keary Suska
On Nov 8, 2010, at 8:01 AM, Vincent Habchi wrote:

> Hi everybody,
> 
> roughly, I would like to set up a view with radio buttons laid out on random 
> places (well, actually not random, but from the buttons point of view, yes). 
> I suppose I can't use a NSMatrix, so I'll have to use regular buttons 
> (mimicking radio ones) and simulate radio behavior in my controller, is that 
> right?

Well, kind of. You can still use radio buttons--you will simply have to mimic 
the "radio" effect across the unrelated buttons. Not difficult really...

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: Resizable NSTabView

2010-11-04 Thread Keary Suska
On Nov 4, 2010, at 7:54 AM, Richard Somers wrote:

> Apple's documentation indicates that a NSToolbar with selectable items can be 
> used for navigation in a preference panel. This is often used in conjunction 
> with an NSTabView that is configured to have no visible tabs.
> 
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Toolbars/Tasks/SelectableItems.html
> 
> In many of Apple's preference panels (Mail, Safari, Finder) the bottom edge 
> of the window moves up an down to accommodate the different view heights.
> 
> Is there a way in Interface Builder to set a dynamic NSTabView height?

No, and there is no API call to do this for you either. You have to do all the 
resizing yourself via code, and watch out for overlapping view gotchas.

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: won't work call from uitableview cell

2010-11-04 Thread Keary Suska
On Nov 3, 2010, at 11:36 AM, Субач Павел Витальевич wrote:

> Need some help, i want call from choose cell in my table with phone number:
> 
> - (void)tableView:(UITableView *)tableView 
> didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
>   NSString *phoneString = [NSString stringWithFormat:@"tel://%@", 
> [dataArray objectAtIndex:indexPath.row]];
>   [[UIApplication sharedApplication] openURL:[NSURL 
> URLWithString:phoneString]];
> }

Technically the URL scheme is tel:# (no "//"), so that may be an issue.

> And second question, how i can get phone number from cell with mix content 
> (how recognize phone number in string)? 
> such as [13880023323 office 302]
>   phone text   number

Only UITextView and UIWebView have data detectors (AFAIK), but there is no 
programmatic interface to them that I know of so you will have to parse the 
numbers you will have to extract the relevant portion manually.

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: Why would [NSArrayController setSelectionIndex] fail?

2010-10-27 Thread Keary Suska
On Oct 27, 2010, at 3:30 PM, vincent habchi wrote:

> Small question: I have a NSArrayController managing a Core data entity array. 
> I want to alter the selection via -setSelectionIndex, and it fails (the index 
> won't change). The documentation is (also) rather terse on the possible 
> causes for such a failure – I do no edition, I just want to pick up an entity 
> through a dialog. Does someone have a little experience with these cases? 
> Especially, how to dig up to the point responsible for the denial?

Do you mean the method is returning NO, or you just don't notice a selection 
change? Note that if a table view is bound to the controller, its delegate must 
approve the selection change as well.

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: Make NSTextField register changes immediately

2010-10-26 Thread Keary Suska
On Oct 26, 2010, at 1:14 PM, James Walker wrote:

> I have an NSTextField with its value bound to a numeric property, and I'd 
> like that value to change as soon as any typing occurs, without forcing the 
> user to type enter or tab.  Here's what I've tried:
> 
> Check the "Continuous" control attribute.  No effect.
> 
> Check "Validates Immediately" on the binding.  No effect.

You didn't think to check "Continuously updates value" in binding options?

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: [Q] Using NSInvocation vs. selector with NSTimer

2010-10-18 Thread Keary Suska
On Oct 18, 2010, at 9:00 AM, JongAm Park wrote:

>>> Is there any benefit in using it? My guess is that an NSInvocation instance 
>>> is used repeatedly, but using the "selector" based method is not 
>>> inconvenient for the most of cases.
>>> Is there any other benefit in using the NSInvocation?
>> 
>> NSInvocation is a very flexible class, and can be used for a wide variety of 
>> tasks, but it is also (therefore) more cumbersome to setup and use for the 
>> simpler things that you mention. It is not often used, so if you don't know 
>> that you need it, you probably don't.
> 
> Well, what I asked actually is about the design philosophy and what the 
> intention of creating of that was. Your last statement can't fulfill my 
> curiosity. :)

The common design use would be situations where the method you wish the timer 
to call requires additional data that would be passed as arguments. Essentially 
the point of using invocations is to permit the timer to call any method 
whatsoever, regardless of the method signature.

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: NSRegularExpression only finds a single occurrence of my match

2010-10-17 Thread Keary Suska
On Oct 17, 2010, at 12:38 AM, Devraj Mukherjee wrote:

> Hi all,
> 
> I am trying to use Regular Expressions to match uppercase letters in
> strings like "numberOfNames" which I want to replace with
> number_of_names. Code sample
> 
> 
>   NSError *error = NULL;  
>   NSRegularExpression *regex = [NSRegularExpression
> regularExpressionWithPattern:@"[a-z]+([A-Z][a-z]+)*"
>   
>
> options:NSRegularExpressionAllowCommentsAndWhitespace
>   
>  
> error:&error];
>   
>   
>   NSMutableString *aStr = [NSMutableString
> stringWithString:@"numberOfElementsAtHome"];
>   NSLog(@"%i", [regex numberOfMatchesInString:aStr
>   
> options:NSRegularExpressionCaseInsensitive
> 
> range:NSMakeRange(0, [aStr length])]);
> 
> In all cases my regular expressions matches one occurrence.
> 
> Can anyone see what I might be getting wrong?

options: *NSRegularExpressionCaseInsensitive*

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: Loading a Nib file

2010-10-16 Thread Keary Suska
On Oct 16, 2010, at 9:41 AM, Hrishikesh Murukkathampoondi wrote:

> I am trying to learn how to open a second window in an Application (Mac OS X, 
> not iOS). I have created a separate Nib file for loading the second window. I 
> have a couple of questions
> 
> 
> Q1. The "Resource Programming Guide" says the following
> 
> "The NSWindowController class also provides automatic support for loading nib 
> files. If you create custom window controllers programmatically, you have the 
> option of initializing them with an NSWindow object or with the name of a nib 
> file. If you choose the latter option, the NSWindowController class 
> automatically loads the specified nib file the first time a client tries to 
> access the window. After that, the window controller keeps the window around 
> in memory; it does not reload it from the nib file, even if the window’s 
> “Release when closed” attribute is set in Interface Builder."
> 
> I have created a Nib file (MySecondWindow.xib), I also created a 
> NSWindowController class (MyWinController). In IB the "File's Owner" of the 
> new Nib file is set to MyWinController.
> 
> 
> I guess I can show the second window by doing something like this in some 
> method in MyDocument.m -
> 
> mySecondWin = [[MyWinController alloc] 
> initWithWindowNibName:@"MySecondWindow"];

Juts to be clear, starting with this yes, but that method alone isn't 
sufficient to actually show the window.

> How do I release the memory once the window is closed? The description above 
> says that the window is kept in memory even if closed.

http://lmgtfy.com/?q=nswindowcontroller+release+when+window+closed

> Q2. In the same "Resource Programming Guide" a later section talks about 
> loading Nib files programmatically using NSBundle and NSNib classes to load a 
> new Nib. Using NSNib allows you to keep the NSNib object around to load 
> additional "copies" of the same type of window (with other controllers).
> 
> Releasing the NSNib object and any mySecondWin controller objects will 
> release all memory associated with MySecondWindow. Correct?

Usually, but not necessarily, as there could be a retain cycle with the File's 
Owner. As long as you do not bind to File's Owner, or have retained outlets to 
same, the objects created from the nib will almost always get released.

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: Smooth scrolling in NSScrollView

2010-10-15 Thread Keary Suska
On Oct 15, 2010, at 8:50 AM, Gideon King wrote:

> Thanks for the suggestion Uli.
> 
> The subviews are layer backed views. I've stripped them down to simply 
> drawing the color into a path - absolutely nothing unusual or complex there.
> 
> Now this is rather embarrassing, but I found out that the cause of the visual 
> slowdown was entirely due to running in the debugger. For some reason, it 
> switches between the program and something else (presumably the debugger) at 
> exactly that point in the program the first time the views are displayed.  
> 
> But I also found that the subviews are getting redrawn whenever the scroll is 
> done and that view is on the screen. So in my animation, it redraws every 
> frame. This is rather disturbing since I would have expected the layer to 
> cache the image of the view and for that to be used when scrolling. If anyone 
> can shed light on that, it'd be greatly appreciated.

What is the NSClipView's -copiesOnScroll value?

> On 15/10/2010, at 8:13 PM, Uli Kusterer wrote:
> 
>> 
>> Have you run the profiler (Shark/Instruments)? That may give some clues 
>> regarding what is causing the slowdown. "deduction" is rarely a good choice 
>> when trying to optimize code.
>> 
>> Also, what kinds of views are in your scroll view? Are those standard system 
>> views (and if yes, which ones and with what content), or custom views of 
>> your own? Have you checked whether you are doing any unnecessarily repeated 
>> drawing that you could be cacheing to speed up the views, or display of a 
>> table view or whatever?

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: main window disappears on resize

2010-10-12 Thread Keary Suska
On Oct 11, 2010, at 7:30 PM, Shane wrote:

>>> I have a minimum size set like 800x400, but max is 0x0, but it's also
>>> unchecked. Something else I've noticed is that this happens in the IB
>>> simulator as well, so I don't believe it's my code, but something in
>>> IB.
>> 
>> And if you set the max values, does the problem go away? I think I came 
>> across a problem where max values were being set to 0, even when unchecked 
>> in IB.
>> 
> 
> Bummer, that didn't work either. Thanks though.

May also be a corrupt xib--have you tried deleting/recreating the window?

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: Trouble binding against transient Core Data property

2010-10-11 Thread Keary Suska
On Oct 11, 2010, at 3:41 PM, Rick Mann wrote:

>   [view bind: @"frame" toObject: controller withKeyPath: 
> @"representedObject.frame" options: nil];
> 
> And, nope. Now the value in the model puts the view in the specified place, 
> but changing the view's frame does not propagate the change to the model. 
> Does that mean that -[NSView frame] is not KVC-compliant, or that I still 
> need custom code somewhere to create the binding?

NSView's "frame" is not an observable property, AFAIK. Generally the rule is, 
if the docs don't say it is observable, don't assume that it is or rely on 
future behavior if it acts as if it does.

Instead, you can register for NSViewFrameDidChangeNotification (see also 
-setPostsFrameChangedNotifications:).

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: main window disappears on resize

2010-10-11 Thread Keary Suska

On Oct 11, 2010, at 1:36 PM, Shane wrote:

>> One thing to check is that you don't have a maximum size set in IB that 
>> happens to be zero. After a resize it might be trying to enforce that, 
>> making the window shrink to nothing, rather than sending it offscreen. Can 
>> you log the frame size and origin after the resize? That would help you to 
>> determine where the window went.
>> 
> 
> I have a minimum size set like 800x400, but max is 0x0, but it's also
> unchecked. Something else I've noticed is that this happens in the IB
> simulator as well, so I don't believe it's my code, but something in
> IB.

And if you set the max values, does the problem go away? I think I came across 
a problem where max values were being set to 0, even when unchecked in IB.

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: NSDictionary setValue KVO

2010-10-10 Thread Keary Suska
On Oct 10, 2010, at 5:54 AM, Trygve Inda wrote:

> I have a controller object with an ivar "myDict"
> 
> I have a nib with an NSArrayController bound to this object with a keypath
> of mydi...@allvalues
> 
> This works, but when I want to add an item to the dict (and have it
> reflected in the arraycontroller), the method in my object is:
> 
> [self willChangeValueForKey:@"myDict"];
> 
> NSDictionary*  test =
> [NSDictionary dictionaryWithObjectsAndKeys:@"someValue", @"someKey", nil];
> 
> [myDict setValue:test forKey:@"someOtherKey"];
> 
> [self didChangeValueForKey:@"myDict"];
> 
> 
> This works too, but how can I do this without the willChange/didChange ?
> 
> Shoudln't the setValue call, fire a KVO message?

NSDictionary does not emit any notices when the collection itself is mutated, 
or when keys change. Have you tried using an NSDictionaryController instead?

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: clarifications about coredata sub to-many entities fetching

2010-10-09 Thread Keary Suska
On Oct 9, 2010, at 3:55 AM, Nicolas Berloquin wrote:

>  I'm fairly new at using coreData on and I'd like to have some
> clarifications on managedObjects and contexts usage.

Honestly, it seems like you are trying to learn the API without reading the API 
docs. For instance, the "Table View Programming Guide for iPhone OS" addresses 
the kind of drill down you are describing, and NSIndexPath has nothing to do 
with it.

You really should understand how UITableViews work first, and then separately 
understand how Core data works, and then try to put them together. Trying to 
understand them both at the same time, clearly, isn't working. 

It is difficult to give you meaningful answers to your questions as they stem 
from a fundamental lack of understanding of other technologies involved--not 
just core data. Regardless, I will try to touch on a few issues that may help 
point in you in some directions.

> I have a model where a top entity has a couple to-many relationships, which
> each have to-many relationships
> to other entities.
> something like this :
> 
> A
> to-many -> B
> to-many -> C
> 
> B
> to-many -> D
> 
> C
> to-many -> E
> 
> (I skipped the other attributes in the entities)
> 
> I have a set of As, that I fetch when my app loads, and I dig into As
> through a UITableView.
> I show a list of As, and when the user taps an A, I show a detail view of
> its contents.
> The user can then access the table of Bs and Cs. And add Ds and Es...
> 
> What I'd like to know is what I should do when I show the list of Bs for
> example.

It is probably better to traverse the relationship rather than manually 
fetching.

> Should I do a new fetch (with a different fetchRequest) on the Bs, and have
> this as a new context ?

Why would you need a new context at all? Re-read the Core Data docs and 
understand what NSManagedObjectContext is and what it is for.

> I'm not sure how do NSIndexPath work with my setup ?

Probably not relevant at all. Read the table view programming guide to 
understand what NSIndexPath is for, as well how to do a hierarchical drill-down.

> On the other hand, the same data has already been loaded when I loaded the 
> As. (well, they may have only been faulted). Is it usual to "re-load" some 
> parts of the tree ?

Yes, the relationships will be faults until they are accessed. When accessed, 
Core data will fetch them for you--but it will only fetch what is necessary to 
fulfill the fault. Specifically, it will not fetch the entire data subtree. 
That would be terribly inefficient.

> Also, when adding Ds should I pass the managed B object to my BviewController 
> and do
> [Binstance addDObject: newD]; or have B as the base of the new context and do 
> [NSEntityDescription insertNewObjectForEntityForName:@"D" ...] or if I didn't 
> do any new fetchRequest (staying with the As), will [Binstance addDObject: 
> newD]; still do the relevant work in the hierarchy ?

Core Data will maintain relational integrity. This is all clearly explained in 
the Core Data Programming Guide.

> and last question (see I'm still a bit confused about the whole thing :)) if 
> I keep the context I got when loading the original As, and I do a [context 
> save:] of new Ds, will it be as efficient as if I was to do the same thing 
> with a context created with Bs as a fetchRequest ?

So far, you have not made a case for needing more than one context. And you 
should avoid doing so until you know Core data better anyway. Anyway, save: 
efficiency between different contexts should only vary based on the number of 
validations and the number of changes that need to be committed.

> I get the feeling that one can use a coredata hierarchy almost as directly as 
> if it was a plain object hierarchy, but I'd like to make sure I'm not missing 
> something along the way !

Yes--you can. That is really the point of Core Data.

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: reused tableViewCell UILabel text is deallocated but not nil ??

2010-10-07 Thread Keary Suska
On Oct 7, 2010, at 8:09 AM, Nicolas Berloquin wrote:

> Hi !
> 
> I have a UITableView that creates/reuses tableViewCells (
> UITableViewCellStyleDefault) on demand, as is usually done,
> ie cellForRowAtIndexPath: uses the same cells over and over.

What do you mean, "uses over and over"? Every cell in the table must be a 
different object. You aren't using the same cell object for every row, are you?

> When I delete a few rows, then add a new one, I crash when I try to set the
> cell's UILabel (right after the cell reuse):
> 
> cell.textLabel.text = myName.titre;

Backtrace?

> I turned on zombies, and I checked with the debugger, and the textLabel's
> _text is the deallocated instance
> (myName.titre is good).

This may be a red herring as the state of _text should not effect the ability 
to assign the property value, generally speaking.

> *** -[CFString class]: message sent to deallocated instance 0x17c370

> Since I'm not handling the cell's contents myself, I don't understand how
> the textLabel can become garbage.
> the text field is supposed to be copied on assignement...

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: Interacting Sizes of NSScrollView and its NSClipView and a Custom NSView

2010-10-04 Thread Keary Suska

On Oct 4, 2010, at 9:22 AM, Thomas Wetmore wrote:

> I have a question based on my confusion over the interacting behaviors of an 
> NSScrollView, its NSClipView and a custom NSView being displayed and clipped.
> 
> I have an NSScrollView which resizes as its window resizes. Therefore the 
> NSClipView resizes within the NSScrollView as the the window resizes.
> 
> The custom NSView being displayed is small enough in size so that by 
> enlarging the window far enough the NSClipView can become larger than the 
> custom NSView. At this point the custom NSView becomes "locked" to the lower 
> left corner of the NSScrollView and extra space is added to the top and right 
> margins outside the bounds of the custom NSView.
> 
> I would like the custom NSView to "float" in the middle of the NSScrollView 
> under these conditions. Other applications seem to implement this behavior. 
> I've been experimenting with settings but haven't been able to figure out how 
> to get what I want.
> 
> For the time being I have added the window delegate method 
> windowWillResize:toSize: to force the window to stop growing at the point 
> where the NSClipView reaches the same size as the custom NSView, so at least 
> things look nice and neat, with the scroll bars going inactive at the exact 
> point where the window stops growing, but I'd rather have the floating 
> behavior.
> 
> Can anyone offer any advice?

Yes: http://lmgtfy.com/?q=center+view+in+nsscrollview

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 get selected text in a WebView

2010-10-04 Thread Keary Suska
On Oct 4, 2010, at 1:15 AM, Gerriet M. Denkmann wrote:

> I have a Webview, and I want to do something with the selected text.
> 
> I tried: 
> DOMRange *dr = [ webView selectedDOMRange ];
> NSString *m = [ dr markupString ];
> this contains the selected characters, but buried in lots of markup language. 
> But I just want the characters.
> 
> NSString *s= [ dr stringRepresentation ];
> just returns "Undefined".
> 
> I could do [webView copy:nil ]; and then get the string from the general 
> pasteboard, but I rather do not like to mess up the pasteboard - the user 
> might have put something important there.

The first thing I would try is use NSAttributedString to convert the HTML.

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: Changing classes

2010-09-30 Thread Keary Suska
On Sep 30, 2010, at 1:28 PM, Remco Poelstra wrote:

> Hi,
> 
> I've a class that represents a general piece of hardware. Subclasses of that 
> class represent more specific versions of that hardware. When I scan the 
> network for hardware, I first only know some basic properties of the hardware 
> and only after some more queries I'll know all details. I thought it would be 
> a good thing to instantiate from the base class when I detect the hardware 
> and then change the class to a more specific class as I find out more about 
> the hardware.
> But how do I change a class? I know about the ISA pointer, but changing it 
> doesn't allocate any additional variables.
> What would be a nice solution to this problem?

Why not just allocate a new object to replace the existing one? E.g.:

id hardware = [[HardWare alloc] init];
[someDictionary setObject:hardware forKey:@"newHardware"];
[hardware release]; // owned only by dict
...
// now you know the specific hw properties
USBHardware *usbHardWare = [[USBHardware alloc] init];
[someDictionary setObject: usbHardWare forKey:@"newHardware"];
[usbHardWare release];

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: Background-Task (Timer)

2010-09-29 Thread Keary Suska
On Sep 29, 2010, at 2:54 AM, Lukas Tenbrink wrote:

> I've got a question about background tasking, and I couldn't really answer 
> myself it by searching in the documentation (or even in the internet).
> I want to make a background task with an application. Firstly, I used the 
> code they gave as a sample, which looks like this:

> It actually shows my local notification, but I want the application to check 
> for some conditions (like "Is the Device charging?" or "In what way does the 
> user hold the device?"), and if certain conditions are complied with, I want 
> to show the local notification. So I only want that the Device sends me a 
> message from time to time (like every 10 seconds), then I execute a little 
> bit of code, and maybe show this notification.
> 
> Does somebody know if this is possible? Thanks in before,

Long running (and especially perpetual) background tasks are not permitted. If 
your app isn't rejected by Apple outright, your app will be force terminated by 
the OS anyway after the max time is reached. You can read more about this in 
the IOS Human Interface Guidelines.

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: Converting an AttributedString into NSData for an NSTextView

2010-09-25 Thread Keary Suska
On Sep 25, 2010, at 10:06 AM, Brad Stone wrote:

> I've been programming in Cocoa for 12 months now so I may not understand the 
> subject fully but my NSTextView Data binding is connected to a Core Data 
> attribute of type "Binary Data" (NSData) and this works when I manually type 
> in text, set some attributes like underline or font, save it and reopen it.  

Yes--don't make assumptions about how the API works. You'll just end up saying 
something nonsensical, and respondents can't do much more than point that fact 
out.

Also, if you want useful answers to questions, you need to explain specifically 
what you need to accomplish, and the conditions under which you need to 
accomplish it. E.g., bindings will usually change an entire scenario.

> Since I have 4,000 files to cycle through I want to do this all 
> programatically.  To simplify things I tried to do this with an NSString 
> instead of an NSAttributableString.  I wrote a test app that creates a new 
> document, pulls the entity "newNote" and uses the following code to set the 
> NSData object:
> 
> NSData *noteData = [s dataUsingEncoding:NSUnicodeStringEncoding]; 
> [newNote setValue:noteData forKey:@"noteData"];
>   
> I then save the document and loop around again.  This works fine with the 
> NSString.  After the 4,000 are loaded in, if I open one of the documents in 
> my interface and look in the textView I see the string.  I guess don't fully 
> understand how to repeat this process with an AttributedString.  I don't see 
> how NSTextStorage applies in this scenario.  Maybe I'm skipping a step.

What, specifically, don't you get? What method calls have you tried? Have you 
read the "Attributed String Programming Guide"?

> On Sep 25, 2010, at 11:28 AM, Keary Suska wrote:
> 
>> 
>> On Sep 25, 2010, at 9:12 AM, Brad Stone wrote:
>> 
>>> I have an NSMutableString that I want to set as the NSData source for an 
>>> NSTextView.  I'm stuck and don't know how to do it.   I'm importing about 
>>> 4,000 XML files and I have to programmatically create the attributedString 
>>> for each one, there's no way around it.
>>> 
>>> How do I convert an NSMutableString to NSData so it can be the data source 
>>> for an NSTextView?
>> 
>> NSTextView doesn't use NSData as its "data source"--it uses NSTextStorage. 
>> You can get its content as a mutable string using -mutableString and 
>> manipulate 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: Converting an AttributedString into NSData for an NSTextView

2010-09-25 Thread Keary Suska

On Sep 25, 2010, at 9:12 AM, Brad Stone wrote:

> I have an NSMutableString that I want to set as the NSData source for an 
> NSTextView.  I'm stuck and don't know how to do it.   I'm importing about 
> 4,000 XML files and I have to programmatically create the attributedString 
> for each one, there's no way around it.
> 
> How do I convert an NSMutableString to NSData so it can be the data source 
> for an NSTextView?

NSTextView doesn't use NSData as its "data source"--it uses NSTextStorage. You 
can get its content as a mutable string using -mutableString and manipulate 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: NSTableView display issue

2010-09-22 Thread Keary Suska
On Sep 22, 2010, at 1:01 PM, k...@highrolls.net wrote:

> Besides bindings and KVO issues, anything else to look at? I am not using 
> bindings nor is this KVO.

Have you verified that the NSTableView instance you are calling is non-nil 
*and* the expected object?

> On Sep 22, 2010, at 12:12 PM, Quincey Morris wrote:
> 
>> On Sep 22, 2010, at 10:28, k...@highrolls.net wrote:
>> 
>>> I have an NSTableView in an NSSplitView.
>>> 
>>> I call -reloadData and -setNeedsDisplay:YES
>>> 
>>> The table does not redisplay with the new data until the split view is 
>>> resized.  From that point forward it behaves properly with subsequent 
>>> -reloadData and -setNeedsDisplay:YES calls.
>>> 
>>> Is there something basic I am missing here?
>> 
>> No, probably not. It's likely just a bug in your code.
>> 
>> The usual cause of this kind of weirdness is that the table is bound to (or 
>> otherwise KVO-dependent on) a property that's not properly KVO compliant, 
>> and the binding was established before the property was set to its proper 
>> value (in a complex sequence of NIB-loading steps). Often, an unrelated 
>> action (such as resizing the split view) happens to cause the property to be 
>> re-set later, which "fixes" the problem.
>> 
>> Sometimes it's quite hard to see the lack of KVO compliance in your code, or 
>> even to know where to look for it. I'd recommend against thinking in terms 
>> of a flaw in 'reloadData' or 'setNeedsDisplay:'.


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: NSRunLoop behavior

2010-09-22 Thread Keary Suska
On Sep 21, 2010, at 8:30 PM, Rafael Cerioli wrote:

> Ok, thank you for your answer.
> 
> So, you are telling me that [self performSelector:@selector(waitUntilReady) 
> withObject:nil afterDelay:1] is an input source ? What exactly is the input 
> source, my selector or the timer that when fired, will call my selector ? I 
> thought sources were like timers and port and stuff like that, and they were 
> waking up the run loop, which is notifying the observers ?

-performSelector methods may be more like NSTimer objects, which aren't input 
sources per se, but still must be fully processed before a run loop will 
exit/return. I am not sure how run loop observers are notified in these cases 
(I assume same as timers).

Talking about observers, run loop observers are not input sources. Unless you 
specifically mean implementations of CFRunLoopObserver, using the term will 
confuse the issue.

> Another question : say you have two sources (or observers?). The first one to 
> be processed calls a [[NSRunLoop currentRunLoop] runUntilDate:someDate]. Will 
> the second one be processed as the first one never exits ? Will the first one 
> be processed recursively (no...) ?

Generally, you should not be futzing with the run loop unless it is your own 
thread and/or you know what you are doing. Run loops are documented in the 
"Threading Programming Guide"--if you haven't read that thoroughly, you need to 
do so before messing with run loops. Also reading the NSRunLoop API docs, which 
indicate that you cannot rely that the main run loop will return at all, as the 
system may attach input sources as part of its operation. That being said, run 
loop operations are synchronous, and you likely need to re-assess your entire 
approach.

> On 2010-09-21, at 9:54 AM, Keary Suska wrote:
> 
>> On Sep 21, 2010, at 5:55 AM, Rafael Cerioli wrote:
>> 
>>> Hi,
>>> 
>>> I'm trying to understand how run loops work. I've written this useless 
>>> piece of code and I'm not sure why "success" does not show up...
>>> What happens is that waitUntilReady never terminates, because it seems that 
>>> the runUntilDate in myButtonAction never ends as well.
>> 
>> Yes, as that is what your code is doing.
>> 
>>> My theory would be that calling a runUntilDate from myButtonAction 
>>> (myButtonAction is started by a run loop observer)  will just prevent other 
>>> sources and observers in the *current* run loop's loop (or run loop's run 
>>> ??) to be processed until myButtonAction terminates.
>> 
>> No--there is no "prevention" whatsoever. -runUntilDate: tells the current 
>> runloop *specifically* to process all input sources, and to not exit until 
>> all sources are processed *and* the specified expiration date has been 
>> reached. 
>> 
>>> So, waitUntilReady's call to runUntilDate would prevent the end of 
>>> myButtonAction's current run loop's loop.
>>> 
>>> Does someone have more info about that ?
>>> 
>>> - (void) myButtonAction {
>>> // A button event has been sent, waking up the run loop and calling 
>>> that method 
>>> 
>>> // this will be called in 1 second
>>> [self performSelector:@selector(waitUntilReady) withObject:nil 
>>> afterDelay:1];
>> 
>> This is an input source, so the runloop will not exit until the method exits.
>> 
>>> // process the current run loop during 10 seconds :
>>> [[NSRunLoop currentRunLoop] runUntilDate:[NSDate 
>>> dateWithTimeIntervalSinceNow:10]];
>> 
>> Which never happens, as you never get to this line, because the method 
>> cannot exit.
>> 
>>> [self setReady:YES];
>>> }
>>> 
>>> - (void) waitUntilReady {
>>> 
>>> while(![self isReady]) {
>>> // this should just process the run loop once :
>>> [[NSRunLoop currentRunLoop]  runUntilDate:[NSDate date]];
>>> }
>>> 
>>> NSLog(@"success!");
>>> }
>> 
>> HTH,
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
> 


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: NSRunLoop behavior

2010-09-21 Thread Keary Suska
On Sep 21, 2010, at 5:55 AM, Rafael Cerioli wrote:

> Hi,
> 
> I'm trying to understand how run loops work. I've written this useless piece 
> of code and I'm not sure why "success" does not show up...
> What happens is that waitUntilReady never terminates, because it seems that 
> the runUntilDate in myButtonAction never ends as well.

Yes, as that is what your code is doing.

> My theory would be that calling a runUntilDate from myButtonAction 
> (myButtonAction is started by a run loop observer)  will just prevent other 
> sources and observers in the *current* run loop's loop (or run loop's run ??) 
> to be processed until myButtonAction terminates.

No--there is no "prevention" whatsoever. -runUntilDate: tells the current 
runloop *specifically* to process all input sources, and to not exit until all 
sources are processed *and* the specified expiration date has been reached. 

> So, waitUntilReady's call to runUntilDate would prevent the end of 
> myButtonAction's current run loop's loop.
> 
> Does someone have more info about that ?
> 
> - (void) myButtonAction {
>   // A button event has been sent, waking up the run loop and calling 
> that method 
> 
>   // this will be called in 1 second
>   [self performSelector:@selector(waitUntilReady) withObject:nil 
> afterDelay:1];

This is an input source, so the runloop will not exit until the method exits.

>   // process the current run loop during 10 seconds :
>   [[NSRunLoop currentRunLoop] runUntilDate:[NSDate 
> dateWithTimeIntervalSinceNow:10]];

Which never happens, as you never get to this line, because the method cannot 
exit.

>   [self setReady:YES];
> }
> 
> - (void) waitUntilReady {
> 
>   while(![self isReady]) {
>   // this should just process the run loop once :
>   [[NSRunLoop currentRunLoop]  runUntilDate:[NSDate date]];
>   }
> 
>   NSLog(@"success!");
> }

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: NSView resizing problems.

2010-09-20 Thread Keary Suska
On Sep 20, 2010, at 5:45 AM, Geoffrey Holden wrote:

> My problem is that when I load this view into a tab (using the attached
> code), the textview doesn't fit on the screen.  It covers up the top
> textfield and seems to have it's top edge somewhere above the tabview (as
> follows)

The most common reason for this is that you are shrinking the view such that it 
forces the subviews to overlap, which creates an undefined situation that the 
view cannot handle.

> Messenger* messenger = [[Messenger alloc] initWithApp:@"Messenger"
> :self];
> [currentConversations setObject:messenger forKey:[NSNumber
> numberWithInt:convId]];

And here is where you are doing it:

> NSView* newView = [[[NSView alloc] init] autorelease];

This is not the designated initializer. Don't do this.

> [newView setAutoresizesSubviews:YES];
> [[messenger view] setFrame:[newView frame]];

Why do you expect [newView frame] to return a sensible value?

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: merging instances of an entity

2010-09-18 Thread Keary Suska
On Sep 18, 2010, at 5:41 AM, Amy Gibbs wrote:

> Hi,
> 
> in a core data app, is there an easy way to 'merge' two instances of an 
> entity, for example where something has been accidentally added twice, and 
> each instance has it's own relationships.

There is no "automatic" or "built-in" way, but Core Data makes changing 
relationships easy, so it will likely be easy.

> I'd like to merge the two instances into a single one where basically all of 
> the second instances relationships are copied to the first instance, then the 
> second instance is deleted. In my scenario I think it would be OK to just 
> 'add' the second instances details to the first, I don't see that anything in 
> the second instance would cause data/relationships to be deleted in the first.
> 
> If I have to do this manually, is it that simple, just copy the relationships 
> (not that I know how to do that but it must be possible) and delete the 
> second instance?

How you handle migrating to-many relationships depends on the merge logic you 
need to use. Whether to-one or to-many, if you are replacing object A's 
relationships with object B's, you can use the direct setter method. Otherwise 
for to-many, you can add one at a time using -mutableSetValueForKey:, deciding 
on an object by object basis whether to add or not. Of course, all of this 
assumes a one-way update (versus a sync, which requires knowing additional 
state info).

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: sort an nstablecolumn to button cell state?

2010-09-17 Thread Keary Suska
On Sep 16, 2010, at 2:09 PM, Michael Hanna wrote:

> I have an NSTableColumn in an NSTableView that has only an
> NSButtonCell(checkbox). When the user clicks the table column header I'd
> like it to sort the table items according to whether or not the checkbox is
> selected. so the end result is that all checked items are grouped
> together(and all unchecked are grouped together).
> 
> Any suggestions on how to do this? I'm aware of the the Sort Key field in
> the Attributes inspector, but it's not obvious to me whether or not this
> will help. I've also set the sort descriptors on the tableview's array
> controller but selection state isn't a property but is derived from from
> other information.

The "state" needs to be a property of the individual model object or accessible 
via a key path. AFAIK, there is no other way when you are using 
bindings/NSArrayController, unless you don't allow the NSArrayController to 
handle sorting (and use NSTableView delegation), but I have never tried that so 
I can't say whether it will 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: Make checkbox in table view uneditable

2010-09-14 Thread Keary Suska

On Sep 14, 2010, at 5:59 PM, Shane Stanley wrote:

> I have a table view using Cocoa bindings, and all columns have editable
> turned off in the Attributes panel. However one column, which contains a
> checkbox cell, steadfastly remains editable.
> 
> I've also tried binding its editable property to a boolean property set to
> NO, but that made no difference.
> 
> Is there some other way I can make a column of checkboxes uneditable, or is
> this a bug?

Checkboxes aren't edit controls, they are buttons, and to my knowledge don't 
even have an "editable" property (even though the table column has such a 
binding). To prevent changing a button state (without significant subclassing) 
you must disable it. In this case, of course, we are talking about NSCells.

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   >