Re: Window cascading

2012-05-09 Thread ecir hana
On Wed, May 9, 2012 at 5:08 AM, Peter Ammon  wrote:

>
> Hope that helps,
>

It did. Thanks!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: saveDocument:

2012-05-09 Thread ecir hana
On Tue, May 8, 2012 at 6:33 PM, Fritz Anderson wrote:

>
> I'll get this wrong if I answer in the amount of time I have. Look up
> "responder chain" in the Mac OS X documentation.
>
> To oversimplify:
>
> Menu commands typically go to the "first responder" — whatever has the UI
> focus. If the focused object doesn't implement the menu item's method, the
> event system shops the event up a logical hierarchy called the "responder
> chain" (e.g. text field -> window -> document -> application) until it
> finds an object that does implement the command. The first object that
> implements the command executes it.
>
> File > Save Document sends saveDocument: to the first responder. Because
> the chain goes from bottom up, the saveDocument: message arrives at the
> document object directly, without mediation from the application's document
> controller.


Thanks.

I apologize but I still don't quite understand. If I just
implement saveDocument: at the document and leave document controller
without it, the menu item is still disabled. When I add saveDocument: to
the controller as well, it works. I mean, if I try to visualize it, if I
just alloc:init: a document it just floats there in memory, how would a
menu know about it? So I need to create it via the document controller, no?
If this is the case, how to propagate the saveDocument: event though
the document controller to the document?

To put it differently, you seems to be saying that that the responder chain
flows the other way than what I thought. Ok, but then how does it know
about the document? When I were doing this in Xcode, I would just connect
the menu item to the first responder and the document from IB would receive
the saveDocument:, right? But there has to be a document controller, I
imagine it is somehow "implied" or "implicit" as in not exposed to the
user, which does the heavy lifting, do I understand this correctly? If so,
what exactly does this document controller do?

I'm sorry for such basic questions I'm very new to all this.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Accessibility issues with NSPopover

2012-05-09 Thread Motti Shneor
Hi everyone.

I am experiencing grave problems setting up decent accessibility on my 
NSPopover. Most issues affect VoiceOver users, but some affect all users (not 
even accessibility). 

1. When NSPopover is shown, VoiceOver will only report the CONTENTS of the 
popover (it will say: "3 items" never any title. I used whatever I could, both 
programmatically and in .xib files, to no avail. I know that my Popover's 
Accessibility description is OK, because if i hit ctrl-option-F2-F2 
(VoiceOver's command for "Window List" The popoever is rightly named.

2. Once my Semi-Transient popoever loses focus, I can not set it back on the 
popover (or any of its subviews). I need to do this programmatically, because 
the accessibility user who lost the focus NEVER HAD A CHANCE to know that this 
popover ever existed.

3. As NSPopover manages its internal window in a very-opaque way, I can't find 
a way THAT WORKS to set up the "initialFirstResponder", or window title, or any 
accessibility attributes on the popover window.

4. I was not able to set up accessibility link from anywhere else in my 
application to the popoever (or one of its subviews).

There is very little documentation and help on NSPopovers, and to say the 
truth, it breaks Apple's most basic Cocoa design. NSPopover is neither Model, 
View or Controller. I wonder...

Please advise...

Motti Shneor, Mac OS X Software Architect & Team Leader
Spectrum Reflections Ltd.
+972-54-3136621



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: iOS launch Music app?

2012-05-09 Thread Eric E. Dolecki
I guess I'll try "music:" and see what happens...




On Tue, May 8, 2012 at 9:03 PM, Michael Crawford wrote:

> Oops.  When I think iTunes, I think desktop.  Sorry for the noise.
>
> -Michael
>
> On May 8, 2012, at 21:00, Kyle Sluder  wrote:
>
> > On May 8, 2012, at 5:53 PM, Michael Crawford wrote:
> >
> >> Have you considered Scripting Bridge?  You can use this to not only
> launch iTunes but also to do anything that can be done using the supported
> AppleScript interface.
> >
> > Subject line says iOS.
> >
> > --Kyle Sluder
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: iOS launch Music app?

2012-05-09 Thread Eric E. Dolecki
This works :)


NSString *stringURL = @"music:";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: self.myTextField.stringValue = @"" fails

2012-05-09 Thread Fritz Anderson
In my experience, setting a text field to the empty string will have it return 
nil when you access the string. I can't quite relate it to the code path you're 
following, but it may be a clue.

— F

On 8 May 2012, at 10:48 PM, Antonio Nunes wrote:

> Why do you recommend against using integerValue? For me it would make more 
> sense to always use integerValue, especially now that I can set the value to 
> 0 to show an empty text field, since we're conceptually representing numbers 
> here, not strings.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: self.myTextField.stringValue = @"" fails

2012-05-09 Thread Roland King
Sorry but that just doesn't make sense. The empty string and nil are just not 
the same thing. If you set a text field's text to the empty string, you will 
get an empty string, you will not get nil. The only way I can imagine this 
happening is if the text field is nil at the point you set the empty (or any 
other) string into it so you didn't really set anything at all. 



On May 9, 2012, at 11:18 PM, Fritz Anderson wrote:

> In my experience, setting a text field to the empty string will have it 
> return nil when you access the string. I can't quite relate it to the code 
> path you're following, but it may be a clue.
> 
>   — F
> 
> On 8 May 2012, at 10:48 PM, Antonio Nunes wrote:
> 
>> Why do you recommend against using integerValue? For me it would make more 
>> sense to always use integerValue, especially now that I can set the value to 
>> 0 to show an empty text field, since we're conceptually representing numbers 
>> here, not strings.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/rols%40rols.org
> 
> This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: saveDocument:

2012-05-09 Thread Fritz Anderson
On 9 May 2012, at 4:45 AM, ecir hana wrote:

> When I were doing this in Xcode, I would just connect
> the menu item to the first responder and the document from IB would receive
> the saveDocument:, right?

"the document from IB" worries me. Your NIB should not include an instance of 
your document (NSDocument-subclass) object. The NSDocument object gets created 
by the global NSDocumentController (see later in this message). The NSDocument 
is represented in the NIB as "File's Owner." An in-NIB NSDocument won't get 
patched into the responder chain, and will disrupt all the connections you make 
in the NIB.

> But there has to be a document controller, I
> imagine it is somehow "implied" or "implicit" as in not exposed to the
> user, which does the heavy lifting, do I understand this correctly? If so,
> what exactly does this document controller do?

You may be using the phrase "document controller" loosely. In a document-based 
application, there is one and only one instance of NSDocumentController (or a 
subclass). It handles the creation and destruction of NSDocument (subclass) 
objects. In the simplest case, an NSDocument is responsible for all the 
"controller" tasks (mediating between model and view), in the "MVC" sense, for 
a document and its views. But that's a different concept.

NSDocument objects are part of the responder chain, which is how they get 
action messages. In the Documentation organizer, search the Lion documentation 
for "responder chain," and select the result labeled "The Responder Chain." 
That should tell you everything you need to know.

— F


-- 
Fritz Anderson -- Xcode 4 Unleashed: Due 21 May 2012 -- 



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Accessibility issues with NSPopover

2012-05-09 Thread Fritz Anderson
On 9 May 2012, at 7:16 AM, Motti Shneor wrote:

> I am experiencing grave problems setting up decent accessibility on my 
> NSPopover. Most issues affect VoiceOver users, but some affect all users (not 
> even accessibility). 

Accessibility can be arcane (and buggy). Your best bet is the accessibility-dev 
list. An accessibility engineer follows it fairly closely.

— F


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: saveDocument:

2012-05-09 Thread Quincey Morris
On May 9, 2012, at 02:45 , ecir hana wrote:

> I apologize but I still don't quite understand. If I just
> implement saveDocument: at the document and leave document controller
> without it, the menu item is still disabled. When I add saveDocument: to
> the controller as well, it works. I mean, if I try to visualize it, if I
> just alloc:init: a document it just floats there in memory, how would a
> menu know about it? So I need to create it via the document controller, no?
> If this is the case, how to propagate the saveDocument: event though
> the document controller to the document?

It's hard to know what you're asking, because you're either using the wrong 
terminology, or you're trying to do something very strange.

NSDocumentController is a frameworks object -- a singleton -- that provides 
shared behavior relating to all documents (such as maintaining the "Recent 
Documents" menu). Except perhaps in some extreme conditions, you wouldn't write 
your own. Very occasionally, it's necessary to subclass the 
NSDocumentController and force the singleton to your own subclass, but this is 
rare.

NSDocument -- well, your subclass of it -- is a *controller* object (in the MVC 
sense) that represents your document file and the windows used to edit it.

The NSDocumentController and your NSDocument-subclass instances are both in the 
responder chain. (There's a different responder chain running through each 
document object.) For information, see:


https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html#//apple_ref/doc/uid/1060i-CH3-SW9

and study the pictures under the heading "Responder Chain for Action Messages" 
-- especially figure 1-10 for document-based apps.

Thus, for example, the 'saveDocument:' action will be normally be delivered to 
the NSDocument-subclass object directly, because it is in the responder chain 
that's active when the menu item is chosen. Note that NSDocument *has* a 
'saveDocument:' method; NSDocumentController doesn't.

The document architecture is described in great detail here:


https://developer.apple.com/library/mac/#documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/Introduction/Introduction.html

You're absolutely wasting your time if you're trying to write Cocoa apps 
without understanding the event architecture (first reference, above). You're 
absolutely wasting your time if you're trying to write a document-based app 
without understanding document architecture (second reference).


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: self.myTextField.stringValue = @"" fails

2012-05-09 Thread Ken Thomases
On May 9, 2012, at 10:30 AM, Roland King wrote:

> On May 9, 2012, at 11:18 PM, Fritz Anderson wrote:
> 
>> In my experience, setting a text field to the empty string will have it 
>> return nil when you access the string. I can't quite relate it to the code 
>> path you're following, but it may be a clue.
> 
> Sorry but that just doesn't make sense. The empty string and nil are just not 
> the same thing. If you set a text field's text to the empty string, you will 
> get an empty string, you will not get nil. The only way I can imagine this 
> happening is if the text field is nil at the point you set the empty (or any 
> other) string into it so you didn't really set anything at all. 

Well, there was a bad claim earlier in the thread about the empty string being 
a "nil string object", but Fritz isn't completely off-base here.  If you bind a 
text field's value to a string property, the string property will typically be 
assigned nil whenever the text field is empty.

That's apparently not involved in the OP's situation, but he's not imagining it.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Accessibility issues with NSPopover

2012-05-09 Thread Kyle Sluder
On May 9, 2012, at 5:16 AM, Motti Shneor  wrote:

> 3. As NSPopover manages its internal window in a very-opaque way, I can't 
> find a way THAT WORKS to set up the "initialFirstResponder", or window title, 
> or any accessibility attributes on the popover window.

Can you override -viewDidMoveToWindow in the appropriate view to set the 
initialFirstResponder on self.window? I agree this is pretty hackish; NSPopover 
should expose initialFirstResponder directly. (Actually, NSViewController 
should probably do that, because anywhere you're adding and removing view 
controllers you're likely going to want to make the appropriate view first 
responder.)

> 
> 4. I was not able to set up accessibility link from anywhere else in my 
> application to the popoever (or one of its subviews).
> 
> There is very little documentation and help on NSPopovers, and to say the 
> truth, it breaks Apple's most basic Cocoa design. NSPopover is neither Model, 
> View or Controller. I wonder...
> 

I wouldn't go this far. I look at NSPopover like NSWindowController. Of course 
you don't have access to the actual window that displays the popover, but the 
same was true for NSDrawer.

At first I didn't understand why NSPopover wasn't itself a subclass of 
NSViewController, but it makes sense that you might want to use NSPopover to 
display pieces of your interface that can appear both within the popover and in 
other places—like torn off in a floating window. Then the architecture of 
NSPopover starts to make mote sense.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Basic Question

2012-05-09 Thread koko
In a subclass of NSView I have implemented:

-(void)print:(id)sender

In IB I have connected a Print  menu item to print: in First Responder.

My print: method is not called.

There is only one instance of print: in the project.

So the basic question is "why would my print: method not becalled?"

-koko
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread Charlie Dickman
As a start change (void) to (IBAction) and have IB re-ingest your .h file with 
the declaration in it.

On May 9, 2012, at 12:33 PM, koko wrote:

> In a subclass of NSView I have implemented:
> 
> -(void)print:(id)sender
> 
> In IB I have connected a Print  menu item to print: in First Responder.
> 
> My print: method is not called.
> 
> There is only one instance of print: in the project.
> 
> So the basic question is "why would my print: method not becalled?"
> 
> -koko
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/3tothe4th%40comcast.net
> 
> This email sent to 3tothe...@comcast.net

Charlie Dickman
3tothe...@comcast.net




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread koko

On May 9, 2012, at 10:45 AM, Charlie Dickman wrote:

> As a start change (void) to (IBAction)

I wanted to avoid that as the documentation for NSView shows 

- (void)print:(id)sender

as the method signature.

-koko


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: iOS launch Music app?

2012-05-09 Thread David Duncan
Please don't rely on undocumented URL schemes. The current set of documented 
schemes can be found here: 
.

As with all undocumented features, they are subject to change without warning.

On May 9, 2012, at 5:55 AM, Eric E. Dolecki wrote:

> This works :)
> 
> 
> NSString *stringURL = @"music:";
> NSURL *url = [NSURL URLWithString:stringURL];
> [[UIApplication sharedApplication] openURL:url];
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread Bill Bumgarner

On May 9, 2012, at 9:47 AM, koko  wrote:

> I wanted to avoid that as the documentation for NSView shows 
> 
> - (void)print:(id)sender
> 
> as the method signature.


IBAction is #def'd as void -- it is just a hook for IB's benefit.

That isn't the problem.

More likely than not, your view isn't first responder or otherwise in the 
responder chain.   Thus, when the AppKit dispatches the action down the 
responder chain, your view isn't in the chain.

b.bum
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread David Duncan
They are the exact same thing (IBAction is primarily a macro for void). In 
fact, unless you are trying to bind directly to the view (which you didn't seem 
to be) it won't make any difference at all.

On May 9, 2012, at 9:47 AM, koko wrote:

> 
> On May 9, 2012, at 10:45 AM, Charlie Dickman wrote:
> 
>> As a start change (void) to (IBAction)
> 
> I wanted to avoid that as the documentation for NSView shows 
> 
> - (void)print:(id)sender
> 
> as the method signature.
> 
> -koko
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread koko
Just an FYI ...

-(void)print:(id)sender 

is defined in the NSPrinting Category on NSView.

-koko




On May 9, 2012, at 10:45 AM, Charlie Dickman wrote:

> As a start change (void) to (IBAction) and have IB re-ingest your .h file 
> with the declaration in it.
> 
> On May 9, 2012, at 12:33 PM, koko wrote:
> 
>> In a subclass of NSView I have implemented:
>> 
>> -(void)print:(id)sender
>> 
>> In IB I have connected a Print  menu item to print: in First Responder.
>> 
>> My print: method is not called.
>> 
>> There is only one instance of print: in the project.
>> 
>> So the basic question is "why would my print: method not becalled?"
>> 
>> -koko
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/3tothe4th%40comcast.net
>> 
>> This email sent to 3tothe...@comcast.net
> 
> Charlie Dickman
> 3tothe...@comcast.net
> 
> 
> 
> 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread koko

On May 9, 2012, at 10:57 AM, Bill Bumgarner wrote:

> or otherwise in the responder chain

I grok that ... thanks.

-koko

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: self.myTextField.stringValue = @"" fails

2012-05-09 Thread Corbin Dunn

On May 8, 2012, at 8:48 PM, Antonio Nunes  wrote:

> On 8 May 2012, at 23:10, Corbin Dunn wrote:
> 
>> 
>> On May 8, 2012, at 1:35 PM, Antonio Nunes  wrote:
>> 
>>> On 8 May 2012, at 21:46, Andy Lee wrote:
>>> 
 Bizarre indeed. Out of curiosity, are you using ARC? Maybe the compiler is 
 confusedly zeroing a non-weak pointer. I'm *really* grasping at straws, 
 though.
>>> 
>>> No ARC. No garbage collection either.
>>> 
 Are there any bindings on the text field? Again, I don't see why it would 
 matter; just wondering.
>>> 
>>> No bindings.
>>> 
> I don't release @"" anywhere, so that is indeed very, very unlikely. 
> Also, if I avoid the exception and assign @"" to a text field a bit later 
> on in another piece of code, it works just fine.
 
 The same text field (toolbarPageNumberTextField), or a different one?
>>> 
>>> Another text field. I'm seeing different behaviour though between letting 
>>> the code run naturally to the empty string assignment and manually moving 
>>> the PC to the line in question. I'll take another look at it after a good 
>>> night's sleep...
>> 
>> You may have a formatter on the cell, and it is returning nil.
>> 
>> Also, you are mixing what you are using the text field for. In some cases 
>> you are treating it like an integer, and in others a string. I don't 
>> recommend using integerValue in your case; instead, convert that integer to 
>> a string (and vice-versa when you read the value via 
>> self.toolbarPageNumberTextField.integerValue). If you fix those things your 
>> problem will probably go away.
> 
> Thanks Corbin,
> 
> Indeed, there is a number formatter on the cell

Okay-- then that is the problem; the formatter is failing to format "" to be a 
number, and giving 'nil' back when you call setStringValue. 

> , so probably that is causing the issue then. To make it possible to have an 
> empty text field when there are no pages in the document I changed the symbol 
> for 0:
>   [self.toolbarPageNumberTextField.formatter setZeroSymbol:@""]; (I did 
> not know this is possible, until a few minutes ago.)

> 
> Then changed all instances of:
>   self.toolbarPageNumberTextField.stringValue = 
> @"";
> 
> to
>   self.toolbarPageNumberTextField.stringValue = 
> @"0";
> 

Did that fix the problem? 


> Following your recommendation I also changed
>   
> self.toolbarPageNumberTextField.integerValue = 
> self.pageListController.selectionIndex + 1;
> to
>   
> self.toolbarPageNumberTextField.stringValue = [NSString 
> stringWithFormat:@"%d", self.pageListController.selectionIndex + 1];
> 
> Why do you recommend against using integerValue? For me it would make more 
> sense to always use integerValue, especially now that I can set the value to 
> 0 to show an empty text field, since we're conceptually representing numbers 
> here, not strings.

Well, it is just more consistent if you treat it all the same. Plus, when you 
read the integerValue, what NSCell doe is creates an NSScanner and scans the 
string (in the cell) for an integer and returns that value. This creates a 
scanner with your current locale...which may or may not be what you want (it 
probably is). When you call setIntegerValue it sets the objectValue of the cell 
to be an NSNumber. It really isn't an issue, but it just flip-flops the value 
type from a string to an integer back and forth. 

corbin


> 
> -António
> 
> 
> 
> ---
> Don't believe everything you think
> ---
> 
> 
> 
> 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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

Array annotation strangeness

2012-05-09 Thread Alex Zavatone
Back on iterating through a mapKit annotation array, I'm bending my brain cell 
on this one.

All my annotations are instances of the MyLocation class

I added a method to expose the properties I want to save by returning a dict to 
the class.

After all annotations are added, and I want to walk the array and build an 
array of annotations, I do this:

- (IBAction)saveData:(id)sender
{   
for (NSDictionary * myAnnotation in self.mapView.annotations)
{
MyLocation *tempLocation = [[MyLocation alloc] init ];

//  test that the methods in the MyLocation objects 
actually work on an empty object
NSString *myString = [tempLocation name];
NSDictionary *myDict = [tempLocation 
returnCoordinatesInDict];
NSDictionary *myStuffDict = [tempLocation 
returnPropertiesInDict];
//  Try it with one of the MyLocation objects in the 
annotation array 
NSDictionary *myGoodsDict = [myAnnotation 
returnPropertiesInDict];

Xcode will not let the last line compile with a "Receiver type 'NSDictionary' 
for instance message does not declare a method with selector 
'returnPropertiesInDict' 

But if I comment out that line, set a breakpoint, it clearly shows that 
myAnnotation is a myLocation instance just like tempLocation.

Does anyone know what I am missing here?

Thanks, 
- Alex

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Array annotation strangeness

2012-05-09 Thread John Pannell
Hi Alex-

When enumerating the array, you've defined the objects in the collection as 
NSDictionary (which doesn't have that method)...

for (NSDictionary * myAnnotation in self.mapView.annotations)

Change the above to:

for (MyLocation * myAnnotation in self.mapView.annotations)

And the compiler should be happier...

Hope this helps!

John


On May 9, 2012, at 12:09 PM, Alex Zavatone wrote:

> Back on iterating through a mapKit annotation array, I'm bending my brain 
> cell on this one.
> 
> All my annotations are instances of the MyLocation class
> 
> I added a method to expose the properties I want to save by returning a dict 
> to the class.
> 
> After all annotations are added, and I want to walk the array and build an 
> array of annotations, I do this:
> 
> - (IBAction)saveData:(id)sender
> { 
>   for (NSDictionary * myAnnotation in self.mapView.annotations)
>   {
>   MyLocation *tempLocation = [[MyLocation alloc] init ];
>   
>   //  test that the methods in the MyLocation objects 
> actually work on an empty object
>   NSString *myString = [tempLocation name];
>   NSDictionary *myDict = [tempLocation 
> returnCoordinatesInDict];
>   NSDictionary *myStuffDict = [tempLocation 
> returnPropertiesInDict];
>   //  Try it with one of the MyLocation objects in the 
> annotation array 
>   NSDictionary *myGoodsDict = [myAnnotation 
> returnPropertiesInDict];
> 
> Xcode will not let the last line compile with a "Receiver type 'NSDictionary' 
> for instance message does not declare a method with selector 
> 'returnPropertiesInDict' 
> 
> But if I comment out that line, set a breakpoint, it clearly shows that 
> myAnnotation is a myLocation instance just like tempLocation.
> 
> Does anyone know what I am missing here?
> 
> Thanks, 
> - Alex
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/john%40positivespinmedia.com
> 
> This email sent to j...@positivespinmedia.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Array annotation strangeness

2012-05-09 Thread Alex Zavatone
This is what I get for copying and pasting code.  

Thank you.

On May 9, 2012, at 2:28 PM, John Pannell wrote:

> Hi Alex-
> 
> When enumerating the array, you've defined the objects in the collection as 
> NSDictionary (which doesn't have that method)...
> 
> for (NSDictionary * myAnnotation in self.mapView.annotations)
> 
> Change the above to:
> 
> for (MyLocation * myAnnotation in self.mapView.annotations)
> 
> And the compiler should be happier...
> 
> Hope this helps!
> 
> John
> 
> 
> On May 9, 2012, at 12:09 PM, Alex Zavatone wrote:
> 
>> Back on iterating through a mapKit annotation array, I'm bending my brain 
>> cell on this one.
>> 
>> All my annotations are instances of the MyLocation class
>> 
>> I added a method to expose the properties I want to save by returning a dict 
>> to the class.
>> 
>> After all annotations are added, and I want to walk the array and build an 
>> array of annotations, I do this:
>> 
>> - (IBAction)saveData:(id)sender
>> {
>>  for (NSDictionary * myAnnotation in self.mapView.annotations)
>>  {
>>  MyLocation *tempLocation = [[MyLocation alloc] init ];
>>  
>>  //  test that the methods in the MyLocation objects 
>> actually work on an empty object
>>  NSString *myString = [tempLocation name];
>>  NSDictionary *myDict = [tempLocation 
>> returnCoordinatesInDict];
>>  NSDictionary *myStuffDict = [tempLocation 
>> returnPropertiesInDict];
>>  //  Try it with one of the MyLocation objects in the 
>> annotation array 
>>  NSDictionary *myGoodsDict = [myAnnotation 
>> returnPropertiesInDict];
>> 
>> Xcode will not let the last line compile with a "Receiver type 
>> 'NSDictionary' for instance message does not declare a method with selector 
>> 'returnPropertiesInDict' 
>> 
>> But if I comment out that line, set a breakpoint, it clearly shows that 
>> myAnnotation is a myLocation instance just like tempLocation.
>> 
>> Does anyone know what I am missing here?
>> 
>> Thanks, 
>> - Alex
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/john%40positivespinmedia.com
>> 
>> This email sent to j...@positivespinmedia.com
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Array annotation strangeness

2012-05-09 Thread David Duncan
On May 9, 2012, at 11:09 AM, Alex Zavatone wrote:

> - (IBAction)saveData:(id)sender
> { 
>   for (NSDictionary * myAnnotation in self.mapView.annotations)

Here you type 'myAnnotation' as an NSDictionary*.

>   NSDictionary *myGoodsDict = [myAnnotation 
> returnPropertiesInDict];
> 
> Xcode will not let the last line compile with a "Receiver type 'NSDictionary' 
> for instance message does not declare a method with selector 
> 'returnPropertiesInDict' 

As such, the compiler tells you that an NSDictionary (which is the type you've 
assured it 'myAnnotation' is) does not implement the method you are trying to 
call on it.

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: self.myTextField.stringValue = @"" fails

2012-05-09 Thread Antonio Nunes
On 9 May 2012, at 19:55, Corbin Dunn wrote:

>> , so probably that is causing the issue then. To make it possible to have an 
>> empty text field when there are no pages in the document I changed the 
>> symbol for 0:
>>  [self.toolbarPageNumberTextField.formatter setZeroSymbol:@""]; (I did 
>> not know this is possible, until a few minutes ago.)
> 
>> 
>> Then changed all instances of:
>>  self.toolbarPageNumberTextField.stringValue = 
>> @"";
>> 
>> to
>>  self.toolbarPageNumberTextField.stringValue = 
>> @"0";
>> 
> 
> Did that fix the problem? 

I think it did. Still need to confirm with the person who initially alerted me 
to the issue, but I can no longer make it crash.

>> Following your recommendation I also changed
>>  
>> self.toolbarPageNumberTextField.integerValue = 
>> self.pageListController.selectionIndex + 1;
>> to
>>  
>> self.toolbarPageNumberTextField.stringValue = [NSString 
>> stringWithFormat:@"%d", self.pageListController.selectionIndex + 1];
>> 
>> Why do you recommend against using integerValue? For me it would make more 
>> sense to always use integerValue, especially now that I can set the value to 
>> 0 to show an empty text field, since we're conceptually representing numbers 
>> here, not strings.
> 
> Well, it is just more consistent if you treat it all the same. Plus, when you 
> read the integerValue, what NSCell doe is creates an NSScanner and scans the 
> string (in the cell) for an integer and returns that value. This creates a 
> scanner with your current locale...which may or may not be what you want (it 
> probably is). When you call setIntegerValue it sets the objectValue of the 
> cell to be an NSNumber. It really isn't an issue, but it just flip-flops the 
> value type from a string to an integer back and forth. 

Thanks for explaining that so clearly Corbin.

-António


It is better to light a candle than to curse the darkness





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Array annotation strangeness

2012-05-09 Thread glenn andreas

On May 9, 2012, at 1:09 PM, Alex Zavatone wrote:

> Back on iterating through a mapKit annotation array, I'm bending my brain 
> cell on this one.
> 
> All my annotations are instances of the MyLocation class
> 
> I added a method to expose the properties I want to save by returning a dict 
> to the class.
> 
> After all annotations are added, and I want to walk the array and build an 
> array of annotations, I do this:
> 
> - (IBAction)saveData:(id)sender
> { 
>   for (NSDictionary * myAnnotation in self.mapView.annotations)
>   {
>   MyLocation *tempLocation = [[MyLocation alloc] init ];
>   
>   //  test that the methods in the MyLocation objects 
> actually work on an empty object
>   NSString *myString = [tempLocation name];
>   NSDictionary *myDict = [tempLocation 
> returnCoordinatesInDict];
>   NSDictionary *myStuffDict = [tempLocation 
> returnPropertiesInDict];
>   //  Try it with one of the MyLocation objects in the 
> annotation array 
>   NSDictionary *myGoodsDict = [myAnnotation 
> returnPropertiesInDict];
> 
> Xcode will not let the last line compile with a "Receiver type 'NSDictionary' 
> for instance message does not declare a method with selector 
> 'returnPropertiesInDict' 
> 
> But if I comment out that line, set a breakpoint, it clearly shows that 
> myAnnotation is a myLocation instance just like tempLocation.
> 
> Does anyone know what I am missing here?


You lied to the compiler.

You told it that myAnnotation was an NSDictionary:
> for (NSDictionary * myAnnotation in self.mapView.annotations)

even though you knew it was suppose to be a MyLocation (and so it rightly 
protested when you tried do [myAnnotation returnPropertiesInDict] since 
NSDictionary doesn't implement returnPropertiesInDict.

Try:
for (MyLocation * myAnnotation in self.mapView.annotations)




Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Array annotation strangeness

2012-05-09 Thread Fritz Anderson
On 9 May 2012, at 1:09 PM, Alex Zavatone wrote:

> Back on iterating through a mapKit annotation array, I'm bending my brain 
> cell on this one.
> 
> All my annotations are instances of the MyLocation class
> 
> I added a method to expose the properties I want to save by returning a dict 
> to the class.
> 
> After all annotations are added, and I want to walk the array and build an 
> array of annotations, I do this:
> 
> - (IBAction)saveData:(id)sender
> { 
>   for (NSDictionary * myAnnotation in self.mapView.annotations)

Assuming .mapView is an MKMapView, then .annotations is an NSArray of objects 
that conform to . From what you say, the objects in the array are 
of class MyLocation, which I gather is not a subclass of NSDictionary. (Leave 
aside that subclassing NSDictionary is ill-advised.)

Therefore your declaration of the myAnnotation loop variable is mistaken: 
Whether you declare the object pointer to be an NSDictionary or not, in point 
of fact the object itself is a MyAnnotation. Objective-C has no C++-like 
concept of producing new, converted objects upon casting.


>   {
>   MyLocation *tempLocation = [[MyLocation alloc] init ];
>   
>   //  test that the methods in the MyLocation objects 
> actually work on an empty object
>   NSString *myString = [tempLocation name];
>   NSDictionary *myDict = [tempLocation 
> returnCoordinatesInDict];
>   NSDictionary *myStuffDict = [tempLocation 
> returnPropertiesInDict];
>   //  Try it with one of the MyLocation objects in the 
> annotation array 
>   NSDictionary *myGoodsDict = [myAnnotation 
> returnPropertiesInDict];
> 
> Xcode will not let the last line compile with a "Receiver type 'NSDictionary' 
> for instance message does not declare a method with selector 
> 'returnPropertiesInDict' 
> 
> But if I comment out that line, set a breakpoint, it clearly shows that 
> myAnnotation is a myLocation instance just like tempLocation.

Yes: a MyLocation. Not an NSDictionary. But you told the compiler that 
myAnnotation is an NSDictionary (even though it isn't), and it doesn't know 
anything different. NSDictionary does not declare a -returnPropertiesInDict 
method, and that's what the compiler is complaining about.

— F

-- 
Fritz Anderson -- Xcode 4 Unleashed: Due 21 May 2012 -- 



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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

crashes loading saved file

2012-05-09 Thread James Maxwell
I've been having problems with my app crashing with an EXC_BAD_ACCESS while 
unarchiving a saved data file. The file is a graph representation of musical 
structure, created by a machine learning algorithm. When the file/graph is 
small there are no problems, but as I add more training material, and the file 
increases in size, at a certain point it starts crashing during unarchiving. 
Strangely, it has no problems saving the file, only unarchiving. The file is 
saved using:

[NSKeyedArchiver archiveRootObject:model toFile:filePath];

Pretty straightforward. NSZombieEnabled gives no info, and code analysis 
reveals no memory warnings. I've been over the code many, many times, and 
haven't been able to track down a reasonable cause. The graph does have 
circular references/loops in some cases (i.e., node B points to a "parent" node 
A, which holds a reference to node B as a "child"), but I doubt that's the 
problem, since smaller files would have the same basic structure -- I used the 
archiveRootObject, which is supposed to deal with this situation (in my 
understanding). 

The last 30 frames of the backtrace:

* thread #1: tid = 0x2603, 0x959f115c CoreFoundation`__CFStringEncodeByteStream 
+ 12, stop reason = EXC_BAD_ACCESS (code=2, address=0xbf81acfc)
frame #0: 0x959f115c CoreFoundation`__CFStringEncodeByteStream + 12
frame #1: 0x95a27a0a CoreFoundation`CFStringGetCString + 922
frame #2: 0x95a683d7 CoreFoundation`-[__NSCFString 
getCString:maxLength:encoding:] + 119
frame #3: 0x9b693190 Foundation`NSClassFromString + 82
frame #4: 0x9b6cb4bf Foundation`_decodeObjectBinary + 2191
frame #5: 0x9b6ccec9 Foundation`-[NSKeyedUnarchiver 
_decodeArrayOfObjectsForKey:] + 1533
frame #6: 0x9b6a06e7 Foundation`-[NSArray(NSArray) initWithCoder:] + 693
frame #7: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #8: 0x9b6caa66 Foundation`_decodeObject + 197
frame #9: 0x0014c017 ManuScore`-[CbCMNode initWithCoder:] + 663 at 
CbCMNode.m:1176
frame #10: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #11: 0x9b6ccec9 Foundation`-[NSKeyedUnarchiver 
_decodeArrayOfObjectsForKey:] + 1533
frame #12: 0x9b6a06e7 Foundation`-[NSArray(NSArray) initWithCoder:] + 693
frame #13: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #14: 0x9b6caa66 Foundation`_decodeObject + 197
frame #15: 0x0014c017 ManuScore`-[CbCMNode initWithCoder:] + 663 at 
CbCMNode.m:1176
frame #16: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #17: 0x9b6ccec9 Foundation`-[NSKeyedUnarchiver 
_decodeArrayOfObjectsForKey:] + 1533
frame #18: 0x9b6a06e7 Foundation`-[NSArray(NSArray) initWithCoder:] + 693
frame #19: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #20: 0x9b6caa66 Foundation`_decodeObject + 197
frame #21: 0x0014c017 ManuScore`-[CbCMNode initWithCoder:] + 663 at 
CbCMNode.m:1176
frame #22: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #23: 0x9b6ccec9 Foundation`-[NSKeyedUnarchiver 
_decodeArrayOfObjectsForKey:] + 1533
frame #24: 0x9b6a06e7 Foundation`-[NSArray(NSArray) initWithCoder:] + 693
frame #25: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #26: 0x9b6caa66 Foundation`_decodeObject + 197
frame #27: 0x0014c017 ManuScore`-[CbCMNode initWithCoder:] + 663 at 
CbCMNode.m:1176
frame #28: 0x9b6cb9c0 Foundation`_decodeObjectBinary + 3472
frame #29: 0x9b6ccec9 Foundation`-[NSKeyedUnarchiver 
_decodeArrayOfObjectsForKey:] + 1533
frame #30: 0x9b6a06e7 Foundation`-[NSArray(NSArray) initWithCoder:] + 693

This morning, I tried enabling Guard Malloc (on its own, without zombies), and 
was surprised to see the app crash during training, with the following error:

GuardMalloc[ManuScore-2438]: Failed to VM allocate 1864016 bytes
GuardMalloc[ManuScore-2438]: Explicitly trapping into debugger!!!


Is it simply running out of VM while trying to build the graph? If so, why 
doesn't this happen with Guard Malloc off? Also, with zombies and guard malloc 
off, why is it only when reading the file that the app crashes, not during 
training (i.e., while the graph is being built)? 

One thing I have noticed, that seems pretty weird, is that the complete 
backtrace when it crashes during unarchiving is 25962 frames long! Could it 
simply be that it's running out of memory while trying to unarchive (i.e., on 
the stack)? If so, how can I get around that? Some sort of caching, perhaps?
The file is only 9.6 MB, so it's not a massive file... 

Any thoughts appreciated.

J.


--
James B. Maxwell
Composer/Researcher/PhD Candidate







___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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/archiv

Re: crashes loading saved file

2012-05-09 Thread Fritz Anderson
On 9 May 2012, at 1:58 PM, James Maxwell wrote:

> This morning, I tried enabling Guard Malloc (on its own, without zombies), 
> and was surprised to see the app crash during training, with the following 
> error:
> 
> GuardMalloc[ManuScore-2438]: Failed to VM allocate 1864016 bytes
> GuardMalloc[ManuScore-2438]: Explicitly trapping into debugger!!!
> 
> 
> Is it simply running out of VM while trying to build the graph? If so, why 
> doesn't this happen with Guard Malloc off? Also, with zombies and guard 
> malloc off, why is it only when reading the file that the app crashes, not 
> during training (i.e., while the graph is being built)? 
> 
> One thing I have noticed, that seems pretty weird, is that the complete 
> backtrace when it crashes during unarchiving is 25962 frames long! Could it 
> simply be that it's running out of memory while trying to unarchive (i.e., on 
> the stack)? If so, how can I get around that? Some sort of caching, perhaps?
> The file is only 9.6 MB, so it's not a massive file... 

1. What kind of memory-management scheme are you using? Garbage collection, 
ARC, or retain-release?

2. Assuming (praying) that you're on a version-control system, consider 
creating a branch and converting the project to ARC. It will make better 
memory-management choices than you will. See if that helps.

3. Are you accumulating lots of temporary (autoreleased) objects? Can you 
investigate embedding code inside loops in @autoreleasepool{...} blocks? 
@autoreleasepool is not an ARC feature. It's usable in any OS target, and ARC / 
ARC conversion don't create local autorelease pools for you.

4. What does the Allocations template in Instruments tell you?

5. Failing all of that, would you be comfortable posting your -initWithCoder: 
methods?

— F


-- 
Fritz Anderson -- Xcode 4 Unleashed: Due 21 May 2012 -- 



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: crashes loading saved file

2012-05-09 Thread Nick Zitzmann

On May 9, 2012, at 12:58 PM, James Maxwell wrote:

> I've been having problems with my app crashing with an EXC_BAD_ACCESS while 
> unarchiving a saved data file. The file is a graph representation of musical 
> structure, created by a machine learning algorithm. When the file/graph is 
> small there are no problems, but as I add more training material, and the 
> file increases in size, at a certain point it starts crashing during 
> unarchiving.

Are you building for OS X or iOS? If the former, then are you building for X86 
or X86-64? If the former, then have you considered transitioning? :)

> This morning, I tried enabling Guard Malloc (on its own, without zombies), 
> and was surprised to see the app crash during training, with the following 
> error:
> 
> GuardMalloc[ManuScore-2438]: Failed to VM allocate 1864016 bytes
> GuardMalloc[ManuScore-2438]: Explicitly trapping into debugger!!!
> 
> 
> Is it simply running out of VM while trying to build the graph?

Yes.

> If so, why doesn't this happen with Guard Malloc off?

Turning Guard Malloc on greatly increases the overall memory usage of the 
process.

> Also, with zombies and guard malloc off, why is it only when reading the file 
> that the app crashes, not during training (i.e., while the graph is being 
> built)? 

You can see for yourself by running your app in Instruments using the object 
allocations instrument. This is just a guess, but what might be happening is 
the reading process is directly or indirectly generating many temporary objects 
that are being pushed into the autorelease/collection pool, which is bulging 
after a while. If you're using RR or ARC memory management, then you can fix 
this by grouping code that generates temporary objects into @autoreleasepool 
blocks. If you're using GC memory management, then you might need to manually 
run the collector more often.

Nick Zitzmann



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread H. Miersch

On 9. May 2012, at 17:58, koko wrote:

> 
> On May 9, 2012, at 10:57 AM, Bill Bumgarner wrote:
> 
>> or otherwise in the responder chain
> 
> I grok that ... thanks.

what does "grok" mean?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread Dave DeLong

On May 9, 2012, at 1:12 PM, H. Miersch wrote:

> what does "grok" mean?

It's a term that roughly means "to completely understand something".

http://en.wikipedia.org/wiki/Grok

Dave
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread Philip Ershler

On May 9, 2012, at 2:12 PM, H. Miersch wrote:

> 
> On 9. May 2012, at 17:58, koko wrote:
> 
>> 
>> On May 9, 2012, at 10:57 AM, Bill Bumgarner wrote:
>> 
>>> or otherwise in the responder chain
>> 
>> I grok that ... thanks.
> 
> what does "grok" mean?
> 

To grok is to intimately and completely share the same reality or line of 
thinking with another physical or conceptual entity. Author Robert A. Heinlein 
coined the term in his best-selling 1961 book Stranger in a Strange Land. In 
Heinlein's view, grokking is the intermingling of intelligence that necessarily 
affects both the observer and the observed.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: crashes loading saved file

2012-05-09 Thread Jens Alfke

On May 9, 2012, at 11:58 AM, James Maxwell wrote:

> Pretty straightforward. NSZombieEnabled gives no info, and code analysis 
> reveals no memory warnings. I've been over the code many, many times, and 
> haven't been able to track down a reasonable cause.

Consider using valgrind. It’s pretty easy to use and can find all sorts of edge 
cases in code, since it’s basically running it in a simulator and watching 
every memory access like a hawk.

You can install it using your favorite package manager (brew, port, etc.)

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: -[NSApp orderOut:] leaves custom sheet in -orderedWindows

2012-05-09 Thread Sean McBride
On Sat, 5 May 2012 10:27:56 -0700, Jerry Krinock said:

>Mac app here, 10.7.
>
>• Show a custom sheet (window) on a document window.
>• Send it an -orderOut:
>• Send [NSApp endSheet:returnCode:]
>
>Expected Result:
>• Sheet should be completely removed from [NSApp orderedWindows].
>
>Actual Result:
>• It is moved to the end of [NSApp orderedWindows].
>
>This sheet has isReleasedWhenClosed:NO and is subclassed directly from
>NSWindow, not NSPanel.  However, I don't think that matters, unless
>NSApp is watching its retainCount, which would be turning the world
>upside down.

Are you using GC?

Sounds a bit like something I saw the other day.  I close a window and 
"shortly" after invoke [NSApp windows] and lo and behold the window I closed is 
still there, for some definitions of "shortly".  If enough time passes, the 
garbage collector does some collecting and the window was collected, I guess.

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: Basic Question

2012-05-09 Thread Graham Cox

On 10/05/2012, at 2:33 AM, koko wrote:

> In a subclass of NSView I have implemented:
> 
> -(void)print:(id)sender
> 
> In IB I have connected a Print  menu item to print: in First Responder.
> 
> My print: method is not called.
> 
> There is only one instance of print: in the project.
> 
> So the basic question is "why would my print: method not becalled?"


The basic answer is because your view isn't First Responder.

To make a view become First Responder you have to do some work - by default a 
view refuses First Responder, so you have to override -acceptsFirstResponder to 
return YES. Even then, it will only be the actual FR if it is clicked on, or 
the window's initialFirstResponder outlet is connected to it. If you want it to 
show a visual highlight when it is FR (keyboard focus ring) then you have to 
draw that highlight.

To handle the Print command, you do not implement the print method. It already 
exists, and it's not usually overridden at that level. Instead, the view by 
default knows how to paginate its bounds to the paper size and will "just work" 
if that standard pagination is what you want. If you want something else, you 
override the various lower level pagination methods. This is all covered in the 
documentation "Printing Programming Topics for Cocoa".

I strongly advise that you read that documentation thoroughly before hacking 
away at implementing print. It's far easier than it seems to implement print, 
but if you hack at it without a proper understanding, also very easy to 
completely stuff up.

--Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: saveDocument:

2012-05-09 Thread Graham Cox

On 09/05/2012, at 7:45 PM, ecir hana wrote:

> I'm sorry for such basic questions I'm very new to all this.



We did warn you that taking yourself down this path wasn't going to be the best 
idea. Now you're seeing why.

If you build a document-based app using Xcode's template, it will work 
correctly from the very first time you run it. Then you can see how it's put 
together, and all of these things will slowly become obvious.

Analogy: if you take apart a clock, you might not understand at first how it 
works, but you have the correct pieces which, when put together properly, would 
make a working clock. By studying these pieces, you could work out how it 
works. What you are doing is starting with sheets of brass and miscellaneous 
screws and trying to make a working clock without having any knowledge of how a 
clock should work, or how it is typically made, beyond perhaps some idea about 
how gears work.

At the very least if you insist on this approach, you should read all of the 
documentation thoroughly, so you understand the (many) concepts that lie behind 
Cocoa's architecture. The behaviour of an application is not down to just one 
object's behaviour, but the intricate interaction between many different 
objects. Stumbling across the correct connections to all of those objects more 
or less by chance is very improbable. But starting with an app already 
correctly working and connected will give you something to study.

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: crashes loading saved file

2012-05-09 Thread James Maxwell
Thanks All,

I'm just using retain-release, so I'll look into converting a version to ARC. 
Unfortunately, I can't go 64-bit as I'm using DrawKit heavily, which doesn't 
seem to support 64-bit builds. I'll also look into @autoreleasepool in certain 
places. I do have a tendency to use the factory methods from NSNumber quite 
often, so there may be cases where I'm creating lots of autoreleased NSNumber 
objects. 
However, I have to admit that I'm not sure how to fix the unarchiving process, 
since the code runs fine while all the learning is happening and the graph is 
being built. It seems to be the unarchiving process in particular that's a 
problem. Is there some other way of periodically draining the pool during the 
unarchiving process?

J.


On 2012-05-09, at 12:55 PM, Fritz Anderson wrote:

> On 9 May 2012, at 1:58 PM, James Maxwell wrote:
> 
>> This morning, I tried enabling Guard Malloc (on its own, without zombies), 
>> and was surprised to see the app crash during training, with the following 
>> error:
>> 
>> GuardMalloc[ManuScore-2438]: Failed to VM allocate 1864016 bytes
>> GuardMalloc[ManuScore-2438]: Explicitly trapping into debugger!!!
>> 
>> 
>> Is it simply running out of VM while trying to build the graph? If so, why 
>> doesn't this happen with Guard Malloc off? Also, with zombies and guard 
>> malloc off, why is it only when reading the file that the app crashes, not 
>> during training (i.e., while the graph is being built)? 
>> 
>> One thing I have noticed, that seems pretty weird, is that the complete 
>> backtrace when it crashes during unarchiving is 25962 frames long! Could it 
>> simply be that it's running out of memory while trying to unarchive (i.e., 
>> on the stack)? If so, how can I get around that? Some sort of caching, 
>> perhaps?
>> The file is only 9.6 MB, so it's not a massive file... 
> 
> 1. What kind of memory-management scheme are you using? Garbage collection, 
> ARC, or retain-release?
> 
> 2. Assuming (praying) that you're on a version-control system, consider 
> creating a branch and converting the project to ARC. It will make better 
> memory-management choices than you will. See if that helps.
> 
> 3. Are you accumulating lots of temporary (autoreleased) objects? Can you 
> investigate embedding code inside loops in @autoreleasepool{...} blocks? 
> @autoreleasepool is not an ARC feature. It's usable in any OS target, and ARC 
> / ARC conversion don't create local autorelease pools for you.
> 
> 4. What does the Allocations template in Instruments tell you?
> 
> 5. Failing all of that, would you be comfortable posting your -initWithCoder: 
> methods?
> 
>   — F
> 
> 
> -- 
> Fritz Anderson -- Xcode 4 Unleashed: Due 21 May 2012 -- 
> 
> 

--
James B. Maxwell
Composer/Researcher/PhD Candidate






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: monitoring changes in a local property

2012-05-09 Thread Koen van der Drift

On May 8, 2012, at 12:27 AM, Quincey Morris wrote:

> P.S. Personally, I wouldn't bind to a NSArrayController like this, because it 
> just obscures the MVC lines of your app. The array controller is getting its 
> content from somewhere: from this view controller itself, from a window 
> controller, or from the app delegate. Assuming the last of these (based on 
> your description of the data as app-wide), then I'd give the app delegate a 
> "selectionIndexes" property (of type NSIndexSet*), bind the array 
> controller's "selectionIndexes" binding to this property in IB, and have the 
> view controller observe the app delegate "selectionIndexes" property instead 
> of the array controller "selectedObjects" property.
> 
> The rationale for this is that the array controller is merely a glue object 
> foisted on you by the bindings UI conventions, and the less your code needs 
> to know about it the better.


Hmmm, an indexset just gives me an index, how do I get the object from it that 
it belongs to? I think I still need to be able to access the NSArrayController 
(that feeds the NSTableView) for that?

Did I miss something?

- Koen.




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: crashes loading saved file

2012-05-09 Thread Graham Cox

On 10/05/2012, at 10:40 AM, James Maxwell wrote:

> Thanks All,
> 
> I'm just using retain-release, so I'll look into converting a version to ARC. 
> Unfortunately, I can't go 64-bit as I'm using DrawKit heavily, which doesn't 
> seem to support 64-bit builds.

While I haven't released DK 64-bit publicly, there's nothing in it that proved 
to be tricky with 64-bit. If you run the 64-bit code conversion tool over it, 
it should pretty much work without a hitch. If you do run into problems, let me 
know privately and I'll help.

--Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: crashes loading saved file

2012-05-09 Thread Roland King
25,962 frames on the stack seems to me rather a lot. Yes unarchiving is a very 
recursive process but that seems pretty deep. 

I missed the start of this thread so I don't know what mechanism you are using 
to archive and unarchive things, but is it possible you've tripped it up and 
it's going around a loop in the object graph and creating the same things over 
and over again (I know the standard archiver/unarchiver classes are coded to 
avoid that but if you have some code of your own, or have found a bug in them 
.. ). I think the best advice there was to look at the allocations screen on 
instruments, sort it by number of objects, it should be very clear very quickly 
if you expect to have made a few hundred of something whilst unarchiving and 
you have 20,000 of them. 

You could take a look at the stack trace as well, see if it looks like it's 
repeating itself, if it does and goes through any of your code then that gives 
you a place to look. 

On May 10, 2012, at 8:40 AM, James Maxwell wrote:

> Thanks All,
> 
> I'm just using retain-release, so I'll look into converting a version to ARC. 
> Unfortunately, I can't go 64-bit as I'm using DrawKit heavily, which doesn't 
> seem to support 64-bit builds. I'll also look into @autoreleasepool in 
> certain places. I do have a tendency to use the factory methods from NSNumber 
> quite often, so there may be cases where I'm creating lots of autoreleased 
> NSNumber objects. 
> However, I have to admit that I'm not sure how to fix the unarchiving 
> process, since the code runs fine while all the learning is happening and the 
> graph is being built. It seems to be the unarchiving process in particular 
> that's a problem. Is there some other way of periodically draining the pool 
> during the unarchiving process?
> 
> J.
> 
> 
> On 2012-05-09, at 12:55 PM, Fritz Anderson wrote:
> 
>> On 9 May 2012, at 1:58 PM, James Maxwell wrote:
>> 
>>> This morning, I tried enabling Guard Malloc (on its own, without zombies), 
>>> and was surprised to see the app crash during training, with the following 
>>> error:
>>> 
>>> GuardMalloc[ManuScore-2438]: Failed to VM allocate 1864016 bytes
>>> GuardMalloc[ManuScore-2438]: Explicitly trapping into debugger!!!
>>> 
>>> 
>>> Is it simply running out of VM while trying to build the graph? If so, why 
>>> doesn't this happen with Guard Malloc off? Also, with zombies and guard 
>>> malloc off, why is it only when reading the file that the app crashes, not 
>>> during training (i.e., while the graph is being built)? 
>>> 
>>> One thing I have noticed, that seems pretty weird, is that the complete 
>>> backtrace when it crashes during unarchiving is 25962 frames long! Could it 
>>> simply be that it's running out of memory while trying to unarchive (i.e., 
>>> on the stack)? If so, how can I get around that? Some sort of caching, 
>>> perhaps?
>>> The file is only 9.6 MB, so it's not a massive file... 
>> 
>> 1. What kind of memory-management scheme are you using? Garbage collection, 
>> ARC, or retain-release?
>> 
>> 2. Assuming (praying) that you're on a version-control system, consider 
>> creating a branch and converting the project to ARC. It will make better 
>> memory-management choices than you will. See if that helps.
>> 
>> 3. Are you accumulating lots of temporary (autoreleased) objects? Can you 
>> investigate embedding code inside loops in @autoreleasepool{...} blocks? 
>> @autoreleasepool is not an ARC feature. It's usable in any OS target, and 
>> ARC / ARC conversion don't create local autorelease pools for you.
>> 
>> 4. What does the Allocations template in Instruments tell you?
>> 
>> 5. Failing all of that, would you be comfortable posting your 
>> -initWithCoder: methods?
>> 
>>  — F
>> 
>> 
>> -- 
>> Fritz Anderson -- Xcode 4 Unleashed: Due 21 May 2012 -- 
>> 
>> 
> 
> --
> James B. Maxwell
> Composer/Researcher/PhD Candidate
> 
> 
> 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/rols%40rols.org
> 
> This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: monitoring changes in a local property

2012-05-09 Thread Quincey Morris
On May 9, 2012, at 18:48 , Koen van der Drift wrote:

> Hmmm, an indexset just gives me an index, how do I get the object from it 
> that it belongs to? I think I still need to be able to access the 
> NSArrayController (that feeds the NSTableView) for that?

The array controller is also bound to some indexed property of your app 
delegate, "myThings". For example, you might have (in the app delegate .h file):

@property (readonly) NSArray* myThings;

Then to get the selected objects:

[appDelegate.myThings objectsAtIndexes: appDelegate.selectionIndexes];

or to get just "the" selected object:

appDelegate.selectionIndexes.count ? [appDelegate.myThings 
objectAtIndex: appDelegate.selectionIndexes.firstIndex] : nil;

Note that what you're doing here is querying the MVC "M" (model) for objects. 
Getting the selected objects from the array controller is (IMO) querying the 
"V" -- because I think of array controllers as effectively part of the view 
complex: they are, after all, typically part of the NIB that defines the view 
components. Technically, they're controllers (mediating controllers, rather 
than coordinating controllers), but my attitude is that they're [semi-]private 
to a sub-MVC system within the main MVC "V". Others might not choose to think 
of them this way.

Anyway, my point is that by querying the "M" rather than the "V", your view 
controller doesn't have dependencies on "V" implementation details. It doesn't 
need to know that there is a table view or an array controller. That's 
*usually* a cleaner design.

(Sometimes it *is* easiest to query the array controller directly -- for 
example, if you need "selectedObjects" or "arrangedObjects" in the sorted 
order.)


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: monitoring changes in a local property

2012-05-09 Thread Koen van der Drift

On May 9, 2012, at 10:12 PM, Quincey Morris wrote:

> The array controller is also bound to some indexed property of your app 
> delegate, "myThings". For example, you might have (in the app delegate .h 
> file):

In my case, the contentset of the array controller is bound to a tree 
controller (which is bound to the MOC of my model).   I fail to see how I also 
bind it to an array.

But to take two steps back, there can only be one item selected at once in 
myThings,  so I really only need to be notified which one that is when the 
selection changes, so that the pane can update its contents. I have another 
'Info' pane where I bind the value of text fields directly to properties of 
self.representedObject.selection in IB (the representedObject is the 
arrayController) But in the other pane I cannot do that, I need to do 
calculations with the selected "Thing", and then display them in a table.  
Which is why I initially used the bind code.  

- Koen.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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: monitoring changes in a local property

2012-05-09 Thread Quincey Morris
On May 9, 2012, at 19:56 , Koen van der Drift wrote:

> In my case, the contentset of the array controller is bound to a tree 
> controller (which is bound to the MOC of my model).   I fail to see how I 
> also bind it to an array.

Well, as to a direct answer, I'm stumped.

If the array controller is in entity mode, AFAICT there's no binding (to the 
data model) that would let the data model keep track of what's selected via 
bindings. There simply appears to be no equivalent to the "selectionIndexes" 
binding when in entity mode.**

So you have 2 choices that I can see:

1. Shrug and have your view controller monitor the array controller's 
"selectedObjects" directly.

2. Have your *app delegate* monitor the array controller's "selectedObjects", 
and provide the result as a public KVO-compliant property. This would keep the 
implementation of how the selection is determined as a private detail of the 
app delegate, preventing the array controller dependency from spreading 
throughout your application design.


** It's possible that NSArrayController maintains "selectionIndexes" when the 
content is a NSOrderedSet, in Lion. In that case, you can maintain (via 
bindings) both a tree "selectionIndexPaths" and an ordered set 
"selectionIndexes" property in the app delegate, then retrieve the selected 
"myThings" objects via a two-step lookup process. I wouldn't bet on it working, 
though.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post 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


__bridge_transfer on a method return value

2012-05-09 Thread Roland King
I'm using CFURLCreateStringByAddingPercentEscapes() because the NSString 
version leaves '+' signs unescaped. If I used it directly in code I'd either 
CFRelease it, or if assigned to an NSString, __bridge_transfer it. However I 
want it as the return value of a method. So I wrote this

+(NSString*)webEncodedString:(NSString *)string
{
CFStringRef retval = CFURLCreateStringByAddingPercentEscapes( 
NULL, (__bridge CFStringRef)string, NULL, CFSTR( "!*'();:@&=+$,/?%#[]" ), 
kCFStringEncodingUTF8 );
return( __bridge_transfer NSString*)retval;
}

My confusion comes from not knowing whether this function now returns an object 
with a +1 refcount or not. If it does it needs to be renamed to have new or 
copy etc in the method name, or annotated properly to show that. My first 
thought was that yes the transfer means the return value has a +1 refcount. 
Then I wondered if the __bridge_transfer transfers ownership to some temporary 
inside the method which will be released as it goes out of scope and do the job 
so all retains/releases are balanced out and the return value does not have an 
extra retain on it. I suppose if I wrote the same thing like this it highlights 
the difference

+(NSString*)webEncodedString:(NSString *)string
{
CFStringRef retval = CFURLCreateStringByAddingPercentEscapes( 
NULL, (__bridge CFStringRef)string, NULL, CFSTR( "!*'();:@&=+$,/?%#[]" ), 
kCFStringEncodingUTF8 );
NSString *temp = (__bridge_transfer)retval;
return temp;
}

Here it would seem the ownership passes to temp, which goes out of scope at the 
end of the method and would release, after I assume some retains/autoreleases 
are done to ensure the object lives long enough to make it back to the caller, 
but still balanced. 

Which is it? 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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