Re: Programmatic Binding

2010-05-18 Thread Richard Somers

On May 18, 2010, at 4:44 PM, Quincey Morris wrote:

1. Setting the frame on a layer that doesn't have a view yet doesn't  
do anything useful. This happens because the 'bind:...' invocation  
is going to cause the setter to be invoked initially, and in your  
non-working case, the view's layer hasn't been set yet.


Oops, I made an error. There was a dependency between the view and the  
layer initialization. Only took me about 1.5 days to find it. It is  
amazing how sometimes you can be blind to your own code. Without help  
from this forum I may have never found the mistake. I think my  
debugging skills have improved and so I want to say thanks for the help.


--Richard

___

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

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


custom formatters and preparedCellAtColumn:row:

2010-05-18 Thread Kurt Bigler
I'm using a custom object type in an NSOutlineView, for which a displayable
text value is obtained from my custom formatter's stringForObjectValue:
method.

To get easy control over text and background colors and alignment for
individual row/columns, I override preparedCellAtColumn:row:.

I'd like a reality check on the following.

My plan is to call stringForObjectValue: from preparedCellAtColumn:row:, and
store the resulting NSString (via setObjectValue:) into the cell that
preparedCell... provides.  It turns out I need the text, to determine the
colorization in some cases.  I figure calling setObjectValue: to replace the
custom class object value with its textual representation would prevent the
cell drawing code from calling stringForObjectValue: *again* to convert the
custom value to text.  It would seem to be a "throw away" situation anyway,
with the cell being reused for the whole column so nothing is lost by
replacing this value at display time.  Right?

I tried it, my app still works, and it appears setObjectValue: is not
getting called except from the preparedCell... override.


Questions are:

* Is it "a good idea" for preparedCell... to replace the custom object value
with the text value like this?

* Does it in any way encumber the reuse of the cell for the entire column?

* Should I be making a copy of the cell passed to preparedCell... and
modifying and returning the copy instead of modifying the provided cell?

* Should I instead be maintaining separate cells per ROWxCOLUMN or perhaps
separate pre-prepared cells for each combinations of text display
attributes?  (There are a finite number of attribute combinations.)


This is all guesswork for me.  I don't find that the doc really helps me
understand this in-depth and I have crafted a lot by trial and error.

Mostly I'd like to avoid creating unnecessary performance hits, since this
outline view gets updated at a high rate by incoming realtime data.


All thoughts are welcome.  Thanks in advance.

-Kurt Bigler


___

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

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

2010-05-18 Thread Greg Guerin

appledev wrote:

arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| / 
usr/bin/grep /dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil];



Your awk syntax is somewhere between quirky and wrong.  Since you  
didn't mention what the problem was, I will assume the output you  
want is not the output you're getting.


I will also assume that you ARE getting some output, despite Alastair  
Houghton previously noted comment that waiting for termination before  
reading stdout can be unsafe.  Unless you have a whole lot of mounted  
disks, the pipe buffer won't fill up and cause deadlock (it's about  
16 KB, empirically determined, in all Mac OS X versions I've tested,  
since 10.0).


Here are the awk problems...

String concatenation in awk is indicated by whitespace.  So this:
print $1 $4 $5 $6

concatenates the strings together, then prints them as a single  
value, followed by the output record separator (newline by default).


If you want the default output field separator, you need this awk line:
print $1, $4, $5, $6

The default output field separator is defined by the awk variable  
named OFS.  To use tab as OFS:

 { OFS="\t"; print $1, $4, $5, $6;}

You can discover all this simply by reading awk's man page.

The resulting bash command-line is:
/bin/df -k| /usr/bin/grep /dev/ | \
  /usr/bin/awk '{ OFS="\t"; print $1, $4, $5, $6;}'

I have inserted a \ to force a continuation line, so mail doesn't  
line-fold badly.


To encode that properly as an Objective-C string literal, you need to  
escape both the double-quotes and the backslash:

arguments = [NSArray arrayWithObjects:
  @"-c",
  @"/bin/df -k| /usr/bin/grep /dev/ | /usr/bin/awk '{ OFS=\"\\t\";  
print $1, $4, $5, $6;}'",

  nil];

(The Objective-C was written in mail and not compiled.  The command- 
line with the modified awk code was tested in bash.)


And I should note that awk is perfectly capable of matching the "/ 
dev/" pattern by itself with no assistance from grep.  This is left  
as an exercise for the interested reader.


  -- GG
___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread Mark Ritchie
Hey James!

On 18/May/2010, at 5:42 PM, James Maxwell wrote:
> Okay, getting a bit deeper into this, I realize I'm still "in the woods", so 
> to speak. I'm going to have to hook up my NSTableView to set the *selected* 
> port and channel for the MIDIInstruments, which means it's pretty much going 
> to have to be loaded in the nib after all (since the MIDIInstrument has to 
> respond to the selection made in the table). So, if I do that, and make the 
> connections to Central_MIDI_Controller, as recommended, will the 
> NSArrayController be able to add new instances of MIDIInstrument (and new 
> rows to my table), which also have these connections? As I mentioned, I need 
> an arbitrary number of MIDIInstruments. 

It seems to me that you are not separating the model, view and controller bits.
To me, MIDIInstrument sounds like it's part of the Model (the internal state of 
things) and it should not be talking directly to the TableView.  The controller 
in the middle should be tracking and co-ordinating things.
I hope that helps!
M.
___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread Mark Ritchie
Hey James!

On 18/May/2010, at 5:26 PM, James Maxwell wrote:
> Anyway, I do like the sound of your design... So, does the instance loaded in 
> IB become a one-off, or does it somehow "alias" (for lack of a better word) 
> all future instances? I was under the impression that the instance in IB was 
> just a single instance, and that it wouldn't have any effect on future 
> instances.

Objects which are unarchived from a nib file are independent of other objects 
already loaded into your application.  That's why File's Owner exists, so that 
the newly instantiated objects can be connected up to objects which already 
exist.

It would seem that I've put you on the wrong path though wrt loading nib files. 
I misunderstood and thought you had  a nib file with an instance of 
MIDIInstrument and it's associated UI already and that's what you were trying 
to hook up.  If that's not the case then what I suggested won't be right.

Such fun.  I see that you've posted more on this.
M.
___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread James Maxwell
okay, there seems to be a big design flaw here... I think this will all be 
simpler if I have a separate MIDI_Instrument_Controller, loaded in the nib, 
which can deal with the table and the Central_MIDI_Controller. Then I'll let 
the NSArrayController deal with instances of the MIDIInstrument itself. I'm 
going to poke away at this for a bit. Sorry for the spam.

J.

On 2010-05-18, at 5:42 PM, James Maxwell wrote:

> ugh...
> 
> Okay, getting a bit deeper into this, I realize I'm still "in the woods", so 
> to speak. I'm going to have to hook up my NSTableView to set the *selected* 
> port and channel for the MIDIInstruments, which means it's pretty much going 
> to have to be loaded in the nib after all (since the MIDIInstrument has to 
> respond to the selection made in the table). So, if I do that, and make the 
> connections to Central_MIDI_Controller, as recommended, will the 
> NSArrayController be able to add new instances of MIDIInstrument (and new 
> rows to my table), which also have these connections? As I mentioned, I need 
> an arbitrary number of MIDIInstruments. 
> 
> Kind of confused about this...
> 
> thanks in advance.
> 
> J.
> 
> 
> On 2010-05-18, at 5:26 PM, James Maxwell wrote:
> 
>> Yes, this is basically what I've done, and it does seem to work...
>> 
>> On 2010-05-18, at 4:49 PM, Jens Alfke wrote:
>> 
>>> 
>>> On May 18, 2010, at 4:28 PM, James Maxwell wrote:
>>> 
 I know this is probably really simple, but how do I grab a reference to a 
 controller object loaded only in the MainMenu.nib file?
>>> 
>>> You can add an outlet to your app controller object pointing to that 
>>> controller object, and then add an accessor method that returns it.
>>> 
>>> @interface MyAppController : NSObject
>>> {
>>> IBOutlet Central_MIDI_Controller* _midiController;
>>> }
>>> @property Central_MIDI_Controller* midiController;
>>> @end
>>> 
>>> 
>>> @implementation MyAppController
>>> @synthesize midiController = _midiController
>>> @end
>>> 
>>> Then just wire up _midiController in IB.
>>> 
>>> —Jens
>> 
>> James B Maxwell
>> Composer/Doctoral Student
>> School for the Contemporary Arts (SCA)
>> School for Interactive Arts + Technology (SIAT)
>> Simon Fraser University
>> jbmaxw...@rubato-music.com
>> jbmax...@sfu.ca
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/jbmaxwell%40rubato-music.com
>> 
>> This email sent to jbmaxw...@rubato-music.com
> 
> James B Maxwell
> Composer/Doctoral Student
> School for the Contemporary Arts (SCA)
> School for Interactive Arts + Technology (SIAT)
> Simon Fraser University
> jbmaxw...@rubato-music.com
> jbmax...@sfu.ca
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/jbmaxwell%40rubato-music.com
> 
> This email sent to jbmaxw...@rubato-music.com

James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
jbmaxw...@rubato-music.com
jbmax...@sfu.ca

___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread James Maxwell
ugh...

Okay, getting a bit deeper into this, I realize I'm still "in the woods", so to 
speak. I'm going to have to hook up my NSTableView to set the *selected* port 
and channel for the MIDIInstruments, which means it's pretty much going to have 
to be loaded in the nib after all (since the MIDIInstrument has to respond to 
the selection made in the table). So, if I do that, and make the connections to 
Central_MIDI_Controller, as recommended, will the NSArrayController be able to 
add new instances of MIDIInstrument (and new rows to my table), which also have 
these connections? As I mentioned, I need an arbitrary number of 
MIDIInstruments. 

Kind of confused about this...

thanks in advance.

J.


On 2010-05-18, at 5:26 PM, James Maxwell wrote:

> Yes, this is basically what I've done, and it does seem to work...
> 
> On 2010-05-18, at 4:49 PM, Jens Alfke wrote:
> 
>> 
>> On May 18, 2010, at 4:28 PM, James Maxwell wrote:
>> 
>>> I know this is probably really simple, but how do I grab a reference to a 
>>> controller object loaded only in the MainMenu.nib file?
>> 
>> You can add an outlet to your app controller object pointing to that 
>> controller object, and then add an accessor method that returns it.
>> 
>> @interface MyAppController : NSObject
>> {
>>  IBOutlet Central_MIDI_Controller* _midiController;
>> }
>> @property Central_MIDI_Controller* midiController;
>> @end
>> 
>> 
>> @implementation MyAppController
>> @synthesize midiController = _midiController
>> @end
>> 
>> Then just wire up _midiController in IB.
>> 
>> —Jens
> 
> James B Maxwell
> Composer/Doctoral Student
> School for the Contemporary Arts (SCA)
> School for Interactive Arts + Technology (SIAT)
> Simon Fraser University
> jbmaxw...@rubato-music.com
> jbmax...@sfu.ca
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/jbmaxwell%40rubato-music.com
> 
> This email sent to jbmaxw...@rubato-music.com

James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
jbmaxw...@rubato-music.com
jbmax...@sfu.ca

___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread James Maxwell
Yes, this is basically what I've done, and it does seem to work...

On 2010-05-18, at 4:49 PM, Jens Alfke wrote:

> 
> On May 18, 2010, at 4:28 PM, James Maxwell wrote:
> 
>> I know this is probably really simple, but how do I grab a reference to a 
>> controller object loaded only in the MainMenu.nib file?
> 
> You can add an outlet to your app controller object pointing to that 
> controller object, and then add an accessor method that returns it.
> 
> @interface MyAppController : NSObject
> {
>   IBOutlet Central_MIDI_Controller* _midiController;
> }
> @property Central_MIDI_Controller* midiController;
> @end
> 
> 
> @implementation MyAppController
> @synthesize midiController = _midiController
> @end
> 
> Then just wire up _midiController in IB.
> 
> —Jens

James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
jbmaxw...@rubato-music.com
jbmax...@sfu.ca

___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread James Maxwell
Hey Mark,

Thanks for this, but it points out one confusion i have. If I thought it would 
be fine to just have MIDIInstrument in the nib, everything would be simple. But 
my (mis)understanding was that putting the MIDIInstrument in the nib would only 
apply to that single instance. Is that not correct? I need to be able to create 
an arbitrary number of MIDIInstrument objects, programmatically (actually, in a 
kind of "Instrument set-up" NSTableView), and for that reason I've avoided 
putting an instance of MIDIInstrument in the nib... 

So, currently, the nib doesn't contain any MIDIInstrument object at all. I load 
MIDIInstrument objects using a "+" button connected to "add" in an 
NSArrayController for MIDIInstruments, which adds rows to an NSTableView. The 
table gives the name, port, channel of the new MIDIInstrument, with default 
values, which the user can then set as desired (just double-click for name, and 
PopUpButtonCells for port and channel). 

Anyway, I do like the sound of your design... So, does the instance loaded in 
IB become a one-off, or does it somehow "alias" (for lack of a better word) all 
future instances? I was under the impression that the instance in IB was just a 
single instance, and that it wouldn't have any effect on future instances.

thanks a lot.

J.




On 2010-05-18, at 5:06 PM, Mark Ritchie wrote:

> On 18/May/2010, at 4:28 PM, James Maxwell wrote:
>> What I'm not understanding is how to allow newly created MIDIInstrument 
>> objects to read the available/enabled ports from Central_MIDI_Controller. I 
>> know this is probably really simple, but how do I grab a reference to a 
>> controller object loaded only in the MainMenu.nib file?
> 
> Hey James,
> I would do it this way:
> Modify the nib file containing the MIDIInstrument so that FilesOwner is class 
> Central_MIDI_Controller.
> Create an outlet on MIDIInstrument which would point to 
> Central_MIDI_Controller.
> In IB, wire up the outlet from MIDIInstrument to FilesOwner.
> Finally change the code which loads the nib containing MIDIInstrument to pass 
> the one instance of Central_MIDI_Controller as the FilesOwner.
> The unarchiving process will handle connecting up the bits at runtime.
> HTH,
> M.

James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
jbmaxw...@rubato-music.com
jbmax...@sfu.ca

___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread Mark Ritchie
Hey James!

On 18/May/2010, at 5:00 PM, James Maxwell wrote:
> From the MIDIInstrument init, I can run [[NSApp delegate] midiController] and 
> get the instance of Central_MIDI_Controller loaded in the nib. As I say, it 
> feels a bit hackish. Though it does work, and advice is still welcome.

Sure, that works in a pinch but doesn't work so well when you might want to 
connect different parent objects to the child objects in the nib file.  Using 
FilesOwner is much more flexible.   And yes, I know that you can change the 
NSApp delegate each time before opening a new nib file (and I might have even 
done that many moons ago ;-) however that is really getting hackish! ;-)
M.
___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread Mark Ritchie
On 18/May/2010, at 4:28 PM, James Maxwell wrote:
> What I'm not understanding is how to allow newly created MIDIInstrument 
> objects to read the available/enabled ports from Central_MIDI_Controller. I 
> know this is probably really simple, but how do I grab a reference to a 
> controller object loaded only in the MainMenu.nib file?

Hey James,
I would do it this way:
Modify the nib file containing the MIDIInstrument so that FilesOwner is class 
Central_MIDI_Controller.
Create an outlet on MIDIInstrument which would point to Central_MIDI_Controller.
In IB, wire up the outlet from MIDIInstrument to FilesOwner.
Finally change the code which loads the nib containing MIDIInstrument to pass 
the one instance of Central_MIDI_Controller as the FilesOwner.
The unarchiving process will handle connecting up the bits at runtime.
HTH,
M.
___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread James Maxwell
okay, so I kind of hacked around it. I gave my AppController (which is a 
delegate of File's Owner) an outlet for the Central_MIDI_Controller, and hooked 
that up in IB. Then I also gave the AppController an accessor for 
"midiController", that returns the reference to Central_MIDI_Controller 
connected in IB. 

From the MIDIInstrument init, I can run [[NSApp delegate] midiController] and 
get the instance of Central_MIDI_Controller loaded in the nib. As I say, it 
feels a bit hackish. Though it does work, and advice is still welcome.

cheers,

J.



On 2010-05-18, at 4:28 PM, James Maxwell wrote:

> 
> Hello All,
> 
> I'm working on MIDI set-up customization for my music app. I have a main 
> controller object, called Central_MIDI_Controller, that uses the VVMIDI 
> framework to detect MIDI ports, and handle low-level MIDI stuff. I have an 
> object called MIDIInstrument, which is a simple wrapper-type object, intended 
> to bundle together a name string with a MIDI port, channel, and some program 
> change "presets", defined by the user. 
> I've put the Central_MIDI_Controller in my MainMenu.nib, and it's settings 
> are stored in the UserDefaults. I put it there because I want it to persist 
> across different documents. What I'm wondering about is how to get the list 
> of available MIDI ports to the MIDIInstrument objects, which will be created 
> dynamically, as the user creates customized instances of MIDIInstrument. 
> What I'm not understanding is how to allow newly created MIDIInstrument 
> objects to read the available/enabled ports from Central_MIDI_Controller. I 
> know this is probably really simple, but how do I grab a reference to a 
> controller object loaded only in the MainMenu.nib file?
> 
> thanks in advance,
> 
> J.
> 
> 
> 
> James B Maxwell
> Composer/Doctoral Student
> School for the Contemporary Arts (SCA)
> School for Interactive Arts + Technology (SIAT)
> Simon Fraser University
> jbmaxw...@rubato-music.com
> jbmax...@sfu.ca
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/jbmaxwell%40rubato-music.com
> 
> This email sent to jbmaxw...@rubato-music.com

James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
jbmaxw...@rubato-music.com
jbmax...@sfu.ca

___

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

Please do not post 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: Get controller from nib

2010-05-18 Thread Jens Alfke

On May 18, 2010, at 4:28 PM, James Maxwell wrote:

> I know this is probably really simple, but how do I grab a reference to a 
> controller object loaded only in the MainMenu.nib file?

You can add an outlet to your app controller object pointing to that controller 
object, and then add an accessor method that returns it.

@interface MyAppController : NSObject
{
IBOutlet Central_MIDI_Controller* _midiController;
}
@property Central_MIDI_Controller* midiController;
@end


@implementation MyAppController
@synthesize midiController = _midiController
@end

Then just wire up _midiController in IB.

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

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


Get controller from nib

2010-05-18 Thread James Maxwell

Hello All,

I'm working on MIDI set-up customization for my music app. I have a main 
controller object, called Central_MIDI_Controller, that uses the VVMIDI 
framework to detect MIDI ports, and handle low-level MIDI stuff. I have an 
object called MIDIInstrument, which is a simple wrapper-type object, intended 
to bundle together a name string with a MIDI port, channel, and some program 
change "presets", defined by the user. 
I've put the Central_MIDI_Controller in my MainMenu.nib, and it's settings are 
stored in the UserDefaults. I put it there because I want it to persist across 
different documents. What I'm wondering about is how to get the list of 
available MIDI ports to the MIDIInstrument objects, which will be created 
dynamically, as the user creates customized instances of MIDIInstrument. 
What I'm not understanding is how to allow newly created MIDIInstrument objects 
to read the available/enabled ports from Central_MIDI_Controller. I know this 
is probably really simple, but how do I grab a reference to a controller object 
loaded only in the MainMenu.nib file?

thanks in advance,

J.



James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
jbmaxw...@rubato-music.com
jbmax...@sfu.ca

___

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

Please do not post 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: singleton design pattern

2010-05-18 Thread Abhinay Kartik Reddyreddy

On May 18, 2010, at 6:42 PM, Mike Abdullah wrote:

> 
> On 18 May 2010, at 23:28, Alejandro Marcos Aragón wrote:
> 
>> Hi all,
>> 
>> I've been staring at this piece of code now to try to find out what's wrong 
>> with it and I can't think of anything at this point. I'm trying to have a 
>> single instance of an NSMutableDictionary inside a class:
>> 
>> 
>> 
>> // in .h file
>> @interface ClassA : NSObject {
>>  
>> }
>> 
>> + (NSMutableDictionary*) uniqueInstance;
>> 
>> @end
>> 
>> // in .m file
>> @implementation ClassA
static NSMutableDictionary* uniqueInstance = nil;
// the static variable has to be initialized before  you enter the 
uniqueInstance method.
>> 
>> 
>> + (NSMutableDictionary*) uniqueInstance {
>>  
>>  //static NSMutableDictionary* uniqueInstance = nil;
> you don't actually need '= nil' unless you prefer it.
> 
>>  
>>  if (uniqueInstance == nil) {
>> 
>>  // directory to save files
>>  NSArray *paths = 
>> NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, 
>> YES);
>>  NSString *dir = [paths objectAtIndex:0];
>>  
>>  NSFileManager *fileManager = [NSFileManager defaultManager];
> uh, this never gets used.
> 
>>  
>>  NSString *customFilePath = [[NSString alloc] initWithString:
>>  [dir 
>> stringByAppendingPathComponent:@"dict.plist"]];
> nonsense, [dir stringByAppendingPathComponent:@"dict.plist"] by itself is 
> what you want.
>> 
>> 
>>uniqueInstance = [[NSMutableDictionary alloc] 
>> initWithContentsOfFile:customFilePath];
>>  }
>>  
>>  return  uniqueInstance;
>> }
>> 
>> 
>> I can't use this code because there is a EXC_BAD_ACCESS according to the 
>> debugger.
> What's the backtrace? Very hard for us to debug without. Your singleton 
> method looks fine provided it's only ever accessed from a single thread at a 
> time. From my comments above, sure you've posted all the relevant code?
>> 
>> I tried moving the definition of the uniqueInstance outside the function and 
>> that didn't help. This code seems alright to me, but I can't find why it 
>> doesn't work. Can someone point out the problem?
>> 
>> aa
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/cocoadev%40mikeabdullah.net
>> 
>> This email sent to cocoa...@mikeabdullah.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:
> http://lists.apple.com/mailman/options/cocoa-dev/karthikreddy09%40gmail.com
> 
> This email sent to karthikredd...@gmail.com

___

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

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

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

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


Re: Programmatic Binding

2010-05-18 Thread Quincey Morris
On May 18, 2010, at 15:21, Richard Somers wrote:

> I have verified that the setter 'setFoo' is being called in all cases so that 
> is not the problem as I originally thought.
> 
> In 'awakeFromNib' when 'bindFoo' is called before 'setView' the layer frame 
> is set but never actually changes to the set value! So the problem is not one 
> of binding but of layer initialization.
> 
> The user default value of foo is 8 which means the first time through 
> 'setFoo' sets the layer frame width and height to 17. But the layer frame 
> width and height never actually get changed but are a value of 1 (not sure 
> where that comes from) which for me is a non-operational layer and causes 
> other problems.

It's a bit hard to tell, because there's too much getting tested at once here, 
but it looks like you have 2 possible problems:

1. Setting the frame on a layer that doesn't have a view yet doesn't do 
anything useful. This happens because the 'bind:...' invocation is going to 
cause the setter to be invoked initially, and in your non-working case, the 
view's layer hasn't been set yet.

and/or

2. The setter is getting called with a value of 0. That would set the width and 
height of the layer to 1.

There may a third thing going on too, but the other things are in the way.

You need to set a breakpoint in the setter and examine to backtrace (call 
stack) to figure out when and why it's being called, I 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: singleton design pattern

2010-05-18 Thread Mike Abdullah

On 18 May 2010, at 23:28, Alejandro Marcos Aragón wrote:

> Hi all,
> 
> I've been staring at this piece of code now to try to find out what's wrong 
> with it and I can't think of anything at this point. I'm trying to have a 
> single instance of an NSMutableDictionary inside a class:
> 
> 
> 
> // in .h file
> @interface ClassA : NSObject {
>   
> }
> 
> + (NSMutableDictionary*) uniqueInstance;
> 
> @end
> 
> // in .m file
> @implementation ClassA
> 
> 
> + (NSMutableDictionary*) uniqueInstance {
>   
>   static NSMutableDictionary* uniqueInstance = nil;
you don't actually need '= nil' unless you prefer it.

>   
>   if (uniqueInstance == nil) {
> 
>   // directory to save files
>   NSArray *paths = 
> NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, 
> YES);
>   NSString *dir = [paths objectAtIndex:0];
>   
>   NSFileManager *fileManager = [NSFileManager defaultManager];
uh, this never gets used.

>   
>   NSString *customFilePath = [[NSString alloc] initWithString:
>   [dir 
> stringByAppendingPathComponent:@"dict.plist"]];
nonsense, [dir stringByAppendingPathComponent:@"dict.plist"] by itself is what 
you want.
> 
> 
> uniqueInstance = [[NSMutableDictionary alloc] 
> initWithContentsOfFile:customFilePath];
>   }
>   
>   return  uniqueInstance;
> }
> 
> 
> I can't use this code because there is a EXC_BAD_ACCESS according to the 
> debugger.
What's the backtrace? Very hard for us to debug without. Your singleton method 
looks fine provided it's only ever accessed from a single thread at a time. 
From my comments above, sure you've posted all the relevant code?
> 
> I tried moving the definition of the uniqueInstance outside the function and 
> that didn't help. This code seems alright to me, but I can't find why it 
> doesn't work. Can someone point out the problem?
> 
> aa
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


singleton design pattern

2010-05-18 Thread Alejandro Marcos Aragón
Hi all,

I've been staring at this piece of code now to try to find out what's wrong 
with it and I can't think of anything at this point. I'm trying to have a 
single instance of an NSMutableDictionary inside a class:



// in .h file
@interface ClassA : NSObject {

}

+ (NSMutableDictionary*) uniqueInstance;

@end

// in .m file
@implementation ClassA


+ (NSMutableDictionary*) uniqueInstance {

static NSMutableDictionary* uniqueInstance = nil;

if (uniqueInstance == nil) {

// directory to save files
NSArray *paths = 
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dir = [paths objectAtIndex:0];

NSFileManager *fileManager = [NSFileManager defaultManager];

NSString *customFilePath = [[NSString alloc] initWithString:
[dir 
stringByAppendingPathComponent:@"dict.plist"]];

  uniqueInstance = [[NSMutableDictionary alloc] 
initWithContentsOfFile:customFilePath];
}

return  uniqueInstance;
}
 

I can't use this code because there is a EXC_BAD_ACCESS according to the 
debugger.

I tried moving the definition of the uniqueInstance outside the function and 
that didn't help. This code seems alright to me, but I can't find why it 
doesn't work. Can someone point out the problem?

aa

___

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

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

2010-05-18 Thread René v Amerongen

Op 18 mei 2010, om 21:48 heeft Stephen J. Butler het volgende geschreven:
>> 
> 
> Depending on what information you need, I'd use [NSWorkspace
> mountedLocalVolumePaths] and then [NSFileManager
> attributesOfFileSystemForPath:error:].
> 

Didn't have NSWorkspace some bugs with giving the right info back about 
mounting points?
I did rdar something and did get a message back as a double.

___

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

Please do not post 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: SETUP : Regular Expressions - Easy Setup for RegexKitLite

2010-05-18 Thread Scott Ribe
On May 15, 2010, at 6:02 PM, Jens Alfke wrote:

> FYI, you don’t have to edit the linker flags anymore to do this. In Xcode 
> 3.1+ you can open the target inspector, choose the General tab, and click the 
> + button at the bottom left to pop up a list of available libraries. Then 
> choose “libicucore.dylib”.

Or, if you like to keep a group for the libraries you've added where you can 
see what's what, right click the group, select Add -> Existing Frameworks, and 
choose the library.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

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

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

2010-05-18 Thread Richard Somers

On May 18, 2010, at 1:40 PM, Quincey Morris wrote:

 If you want an answer, you're going to have to be a bit more  
forthcoming with information.


Is "foo" an instance variable or a property? If instance variable,  
what's the value of accessInstanceVariablesDirectly for its class?  
If a property, is there an @property declaration, and how are its  
getter and setter defined?


Have you verified whether setFoo: is never called, or whether it's  
called with the wrong value? Is the setter called when you  
subsequently change the user default value that foo is bound to? How  
do you know that the user default value is correct? Just knowing  
that foo has the wrong value at some point isn't much help in  
tracking down the problem.


Thanks for being patient and helpful. Foo is an ivar with a getter and  
setter, so that makes it a property.


@interface MyCustomLayer : CAOpenGLLayer

{
@private
 int _foo;
}

@end

@implementation MyCustomLayer

- (int)foo
{
 return _foo;
}

- (void)setFoo:(int)foo
{
 _foo = foo;
 // When foo is changed update the size of the layer.
 CGFloat size = (2 * foo) + 1;
 [self setFrame:CGRectMake(0.0, 0.0, size, size)]; // This is  
where the problem occurs!

}

@end

I have verified that the setter 'setFoo' is being called in all cases  
so that is not the problem as I originally thought.


In 'awakeFromNib' when 'bindFoo' is called before 'setView' the layer  
frame is set but never actually changes to the set value! So the  
problem is not one of binding but of layer initialization.


The user default value of foo is 8 which means the first time through  
'setFoo' sets the layer frame width and height to 17. But the layer  
frame width and height never actually get changed but are a value of 1  
(not sure where that comes from) which for me is a non-operational  
layer and causes other problems.


If the user defaults changes and sets the value of foo a second time  
(after awakeFromNib) then the layer frame width and height gets  
properly set and all is well.


So to recap.

 // In awakeFromNib this works. Layer frame is set to correct  
value.

 layer = [[MyCustomLayer alloc] init];
 [layer setView:self];
 [layer bindFoo];
 ...

 // In awakeFromNib this does not work. Layer frame does not  
properly set.

 layer = [[MyCustomLayer alloc] init];
 [layer bindFoo];
 [layer setView:self];
 ...

I have also tried the following.

 layer = [[MyCustomLayer alloc] init];
 // Do something else here. But the only thing so far
 // that works is [layer setView:self]
 [layer bindFoo];
 ...

Note that I have also tried changing foo from an int to a NSNumber but  
it makes no difference. The layer initialization is very  
temperamental. Originally the layer was in a nib which worked fine. I  
have been refactoring and cleaning up and moving things out of the nib  
that do not really belong there. That is when I ran into this problem.  
It makes me a little nervous that the layer initialization is so  
temperamental.


--Richard

___

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

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

2010-05-18 Thread Jens Alfke

On May 18, 2010, at 3:04 PM, René v Amerongen wrote:

> Maybe just an imagination from me, but it looks slow all that moving of 
> results to the next task.

But that’s exactly what the shell does! The “|” operator spawns a process for 
each side and hooks the output of the first to the input of the second. There’s 
not really any copying going on — pipes are pretty fundamental to the way the 
Unix kernel works and are highly optimized.

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

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


Re: NSTask and piped commands

2010-05-18 Thread René v Amerongen
Thanks for this.

Your right about this idea. I will check it out.

René

Op 18 mei 2010, om 22:34 heeft Alastair Houghton het volgende geschreven:

> On 18 May 2010, at 20:33, appledev wrote:
> 
>>   [task launch];
>> 
>>   [task waitUntilExit];
>>  
>>   NSData *data;
>>   result = [file readDataToEndOfFile];
> 
> This part is not safe.  If the tasks output enough data to fill the pipe 
> buffer (which may be of whatever size the kernel chooses to make it), then 
> your program will hang on the -waitUntilExit line.
> 
> You should instead do something like
> 
>  NSMutableData *result = [NSMutableData data];
>  NSData *chunk;
> 
>  while ((chunk = [file availableData]) && [chunk length])
>[result appendData:chunk];
> 
>  [task waitUntilExit];
> 
> There are obviously variations on that; if you can process the data as you 
> go, that may be a better way to do it (but it's a bit complicated to do 
> because there's no guarantee that the chunks you read won't straddle 
> individual multi-byte characters).
> 
> Kind regards,
> 
> Alastair.
> 
> --
> http://alastairs-place.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSTask and piped commands

2010-05-18 Thread René v Amerongen

Sorry for the late reaction. I did check every ten minutes Cocoabuilder and 
sometimes my mail, but I see that there where all ready replies before I got my 
own posting.

Op 18 mei 2010, om 22:13 heeft Jens Alfke het volgende geschreven:

>> I dont want to use a call to a bash script, because of sneaking in bad 
>> commands.
> 
> As others said, it’s not a problem here because the command line is entirely 
> hardcoded.

With the sample line, yes, but I was thinking of a piece of script on disk 
inside the xx.app folder.

> 
> If you wanted to avoid using a shell, you’d have to start three separate 
> NSTasks for the three commands (df, grep, awk) and hook the output pipe of 
> one to the input of the next. I’m not sure how to do that.

I did think of that and did use that in the past because it was the only way 
that I did know off. Maybe just an imagination from me, but it looks slow all 
that moving of results to the next task.


> 
> Of course, you could skip the grep and awk tasks and do the job yourself — 
> looks like you’re just matching against a string, breaking the lines into 
> pieces and then formatting the result. Probably three or four lines of Obj-C.

Yes!! for the awk command line I will it do it that way.

Anyway, because of other piped command lines that I need, I am still curious 
how to do it with the escaping of the tabs.

Thank you___

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

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

2010-05-18 Thread Jens Alfke

On May 18, 2010, at 2:32 PM, Michael Ash wrote:

> If you need incremental modifications, you'll need to use some other
> storage/serialization strategy, such as SQLite or CoreData.

You can fake it by using an archive whose root object is a mutable dictionary. 
Then you can read the archive, keep the dictionary around and update its keys 
and values, then write it into a new archive and save the data over the file.

I’ve done this in the past and it works well for small to medium size data sets 
(I had something like 1,500 blog posts in it, for example.) But as it grows, it 
starts using more RAM and taking longer to read and save.

There are some storage systems in between  this and a full relational database 
— Tokyo Cabinet is a good example of an on-disk dictionary.

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

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


Re: NSKeyedArchiver: confusion

2010-05-18 Thread Michael Ash
On Tue, May 18, 2010 at 5:21 PM, Matthew Weinstein  wrote:
> My mistake for not being clear:
> I have an NSData in an object;
> I read that data using a keyedArchiver to get to the chunk I want.
>
> I want to replace a chunk of that data with another using the same key. (the 
> file part is immaterial).

You can't do this. NSKeyedArchiver/Unarchiver does not support
in-place modification or partial changes. You must read an entire
archive, and write out a complete new archive.

If you need incremental modifications, you'll need to use some other
storage/serialization strategy, such as SQLite or CoreData.

Mike
___

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

Please do not post 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: iPad interface orientation basics

2010-05-18 Thread David Duncan
On May 17, 2010, at 8:58 AM, sebi wrote:

> I have a ViewController with a view. In that view there is an UIImageView 
> background subview. Now, when I rotate the device I want to switch the image 
> of the UIImageview so it fills the view again without being distorted. The 
> only working method I found out up to now is to determine the correct values 
> for the views frames and bounds by try and error and to hardcode them into 
> the didRotateFromInterfaceOrientation method. Isn't there any example that 
> shows how this is done properly? I downloaded all of apple samplecode and 
> didn't find anything:

Why not just use the autoresizingMask to bind your image view to the size of 
its parent views? Then all you need to do (potentially) is determine if you 
want to display the correct image for landscape or portrait. No need to 
manually fiddle with the frame or bounds of the view at all (unless you want to 
do more complex orientation, in which case go for it).

But the coordinate systems are relatively simple. The frame is your view's 
coordinate system in its parent's coordinate system (that is, where you are in 
the world). The bounds is your view's coordinate system in its own coordinate 
system (that is, what is the extent of your world). It doesn't make sense to 
set your frame in terms of your parent's frame, because that is the wrong 
coordinate system – that would be like trying to locate your house in terms of 
the Earth's location in the Solar System. You can do it, but it is hard and 
there are much easier ways to go about the task.

--
David Duncan
Apple DTS Animation and Printing

___

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

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

2010-05-18 Thread Jeff Kelley
Right, but in your original e-mail, you said, "When I open the file the old 
junk is all there."

If you want the data to be in the file then you'll need to save it to the file. 
When you create the NSMutableData object, it's copied out of the file and into 
memory; you are not operating directly on the file.

What happens if you create a keyed unarchiver immediately after the code you 
sent us and unarchive the object in question?

Jeff Kelley
University of Michigan

On May 18, 2010, at 5:21 PM, Matthew Weinstein wrote:

> My mistake for not being clear:
> I have an NSData in an object;
> I read that data using a keyedArchiver to get to the chunk I want. 
> 
> I want to replace a chunk of that data with another using the same key. (the 
> file part is immaterial).
> 
> 
> On May 18, 2010, at 2:10 PM, Jens Alfke wrote:
> 
>> 
>> On May 18, 2010, at 1:40 PM, Matthew Weinstein wrote:
>> 
>>> The problem: The old @"codedDataArray" is not replaced! When I open the 
>>> file the old junk is all there. The old array is not discarded and replaced 
>>> with the new (myRecs) array. So I cannot use NSKeyedArchiver like an 
>>> NSMutableDictionary?
>> 
>> I’m not sure I understand. Were you expecting the code you posted to write 
>> to the file? But nowhere in that code did you specify what file to write to. 
>> Archivers don’t directly know about files; they work on in-memory data. 
>> (Yes, there are convenience class methods for reading and writing a file, 
>> but they just call NSData methods to transfer the data to/from a file.)
>> 
>> It sounds like what you want to do is call [NSKeyedArchiver 
>> archiveRootObject: obj toFile: file].
>> 
>> —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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSKeyedArchiver: confusion

2010-05-18 Thread Matthew Weinstein
My mistake for not being clear:
I have an NSData in an object;
I read that data using a keyedArchiver to get to the chunk I want. 

I want to replace a chunk of that data with another using the same key. (the 
file part is immaterial).


On May 18, 2010, at 2:10 PM, Jens Alfke wrote:

> 
> On May 18, 2010, at 1:40 PM, Matthew Weinstein wrote:
> 
>> The problem: The old @"codedDataArray" is not replaced! When I open the file 
>> the old junk is all there. The old array is not discarded and replaced with 
>> the new (myRecs) array. So I cannot use NSKeyedArchiver like an 
>> NSMutableDictionary?
> 
> I’m not sure I understand. Were you expecting the code you posted to write to 
> the file? But nowhere in that code did you specify what file to write to. 
> Archivers don’t directly know about files; they work on in-memory data. (Yes, 
> there are convenience class methods for reading and writing a file, but they 
> just call NSData methods to transfer the data to/from a file.)
> 
> It sounds like what you want to do is call [NSKeyedArchiver 
> archiveRootObject: obj toFile: file].
> 
> —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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSKeyedArchiver: confusion

2010-05-18 Thread Jens Alfke

On May 18, 2010, at 1:40 PM, Matthew Weinstein wrote:

> The problem: The old @"codedDataArray" is not replaced! When I open the file 
> the old junk is all there. The old array is not discarded and replaced with 
> the new (myRecs) array. So I cannot use NSKeyedArchiver like an 
> NSMutableDictionary?

I’m not sure I understand. Were you expecting the code you posted to write to 
the file? But nowhere in that code did you specify what file to write to. 
Archivers don’t directly know about files; they work on in-memory data. (Yes, 
there are convenience class methods for reading and writing a file, but they 
just call NSData methods to transfer the data to/from a file.)

It sounds like what you want to do is call [NSKeyedArchiver archiveRootObject: 
obj toFile: file].

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

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


NSKeyedArchiver: confusion

2010-05-18 Thread Matthew Weinstein
Dear Cocoa-dev,
I'm trying to use a keyed archiver to manipulate a file without actually 
opening it. Everything seems fine at first: I get the data, I copy it into a 
NSMutableData object, I init a NSKeyedUnarchiver and get the data I need; I 
create a new object with the old data (an array of dictionaries) with just a 
couple of the keys changed. I dump the new array of modified dictionaries and 
everything looks great. I then try to archive it using the following (where 
theData is my NSMutableData inited with data in a file).


masterOutArray = [[NSKeyedArchiver alloc] initForWritingWithMutableData: 
theData];
[masterOutArray setOutputFormat: NSPropertyListXMLFormat_v1_0];
 [masterOutArray encodeObject: myRecs forKey: @"codedDataArray"];
[masterOutArray finishEncoding];
[masterOutArray release];

The problem: The old @"codedDataArray" is not replaced! When I open the file 
the old junk is all there. The old array is not discarded and replaced with the 
new (myRecs) array. So I cannot use NSKeyedArchiver like an NSMutableDictionary?

Hoping for clarity and possible approaches

Thanks,

Matthew Weinstein


Matthew Weinstein
Associate Professor of Science Education
Education Program
U.W. - Tacoma
253 692-4787

matth...@u.washington.edu

Campus Box: 358435
1900 Commerce Street
Tacoma, WA  98402-3100
Office:  (253) 692-4787
FAX: (253) 692-5612



___

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

Please do not post 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 I can't see my localized nib?

2010-05-18 Thread Gustavo Pizano
So at app start up I can get the Application defaults objectforkey 
"AppleLanguages", then set array with the first object to be "sk_SK" and then 
push the array again back to the application defaults.. right?

And if the user selects for example English I must do the above, and restart 
the application to load the proper language... correct me if Im wrong please... 

thx

Gustavo

On 18.5.2010, at 21:13, Frédéric Testuz wrote:

> Le 18 mai 2010 à 18:28, Joanna Carter a écrit :
> 
>> Hi Gustavo
>> 
>>> In this case.. is tehre anyway to let teh user choose what lang to use?.. I 
>>> mean if I localize my app, but the user has no localization either, how to 
>>> make the app run in a given language (i.e sk)?
>> 
>> The only way I can think of is to delete the other localizations from the 
>> bundle. Maybe someone else knows better :-)
> 
> You can launch the application with AppleLanguages in the arguments or in the 
> app defaults.
> 
> See :
> 
> 
> 
> and
> 
> 
> 
> Frédéric

___

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

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

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 21:35, Jens Alfke wrote:

> On May 18, 2010, at 1:27 PM, Alastair Houghton wrote:
> 
>> Something like the following should work, right?
> 
> That looks right; but you’re proving my point that it’s easier just to do the 
> filtering in native code :)

Well, there is that too :-)

Kind regards,

Alastair.

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

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


Re: NSTask and piped commands

2010-05-18 Thread Jens Alfke

On May 18, 2010, at 1:27 PM, Alastair Houghton wrote:

> Something like the following should work, right?

That looks right; but you’re proving my point that it’s easier just to do the 
filtering in native code :)

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

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


Re: NSTask and piped commands

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 20:33, appledev wrote:

>[task launch];
> 
>[task waitUntilExit];
>   
>NSData *data;
>result = [file readDataToEndOfFile];

This part is not safe.  If the tasks output enough data to fill the pipe buffer 
(which may be of whatever size the kernel chooses to make it), then your 
program will hang on the -waitUntilExit line.

You should instead do something like

  NSMutableData *result = [NSMutableData data];
  NSData *chunk;

  while ((chunk = [file availableData]) && [chunk length])
[result appendData:chunk];

  [task waitUntilExit];

There are obviously variations on that; if you can process the data as you go, 
that may be a better way to do it (but it's a bit complicated to do because 
there's no guarantee that the chunks you read won't straddle individual 
multi-byte characters).

Kind regards,

Alastair.

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

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


Re: NSTask and piped commands

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 21:13, Jens Alfke wrote:

> 
> On May 18, 2010, at 12:33 PM, appledev wrote:
> 
>> I dont want to use a call to a bash script, because of sneaking in bad 
>> commands.
> 
> As others said, it’s not a problem here because the command line is entirely 
> hardcoded.
> 
> If you wanted to avoid using a shell, you’d have to start three separate 
> NSTasks for the three commands (df, grep, awk) and hook the output pipe of 
> one to the input of the next. I’m not sure how to do that.

Something like the following should work, right?

  NSTask *task1 = [[[NSTask alloc] init] autorelease];
  NSTask *task2 = [[[NSTask alloc] init] autorelease];
  NSTask *task3 = [[[NSTask alloc] init] autorelease];
  NSPipe *t1t2pipe = [NSPipe pipe];
  NSPipe *t2t3pipe = [NSPipe pipe];
  NSPipe *outputPipe = [NSPipe pipe];

  [task1 setLaunchPath:@"/bin/df"];
  [task1 setArguments:[NSArray arrayWithObjects:@"-k", nil]];
  [task1 setStandardOutput:t1t2pipe];
  
  [task2 setLaunchPath:@"/usr/bin/grep"];
  [task2 setArguments:[NSArray arrayWithObjects:@"/dev/", nil]];
  [task2 setStandardInput:t1t2pipe];
  [task2 setStandardOutput:t2t3pipe];

  [task3 setLaunchPath:@"/usr/bin/awk"];
  [task3 setArguments:[NSArray arrayWithObjects:@"{print $1 \"\t\" $4 \"\t\" $5 
\"\t\" $6;}", nil]];
  [task3 setStandardInput:t2t3pipe];
  [task3 setStandardOutput:outputPipe];

  [task1 launch];
  [task2 launch];
  [task3 launch];

Kind regards,

Alastair.

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

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


Re: NSTask and piped commands

2010-05-18 Thread Alastair Houghton
On 18 May 2010, at 20:48, Stephen J. Butler wrote:

> On Tue, May 18, 2010 at 2:33 PM, appledev  wrote:
>> I dont want to use a call to a bash script, because of sneaking in bad 
>> commands.
>> But how should I handle this?
> 
> That's only a real concern when you put user supplied data into the
> command you're running. But I don't see you doing that here... you're
> just using bash to parse the otput of some unix command.

Well, you might have to worry about some environment variables also.  IFS could 
be an issue, for instance.  Best not to use the shell from code if you can help 
it.

Kind regards,

Alastair.

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

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


Re: NSTask and piped commands

2010-05-18 Thread Jens Alfke

On May 18, 2010, at 12:33 PM, appledev wrote:

> I dont want to use a call to a bash script, because of sneaking in bad 
> commands.

As others said, it’s not a problem here because the command line is entirely 
hardcoded.

If you wanted to avoid using a shell, you’d have to start three separate 
NSTasks for the three commands (df, grep, awk) and hook the output pipe of one 
to the input of the next. I’m not sure how to do that.

Of course, you could skip the grep and awk tasks and do the job yourself — 
looks like you’re just matching against a string, breaking the lines into 
pieces and then formatting the result. Probably three or four lines of Obj-C.

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

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


Re: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Frédéric

> You can launch the application with AppleLanguages in the arguments or in the 
> app defaults.
> 
> See :
> 
> 
> 
> and
> 
> 


Noted. Thank you.

Joanna

--
Joanna Carter
Carter Consulting

___

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

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

2010-05-18 Thread Stephen J. Butler
On Tue, May 18, 2010 at 2:37 PM, Rick Genter  wrote:
> On May 18, 2010, at 12:33 PM, appledev wrote:
>
>>    NSArray *arguments;
>>    arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| /usr/bin/grep 
>> /dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil];
>>       // arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k", @"| 
>> /usr/bin/grep /dev/ | /usr/bin/awk '{print $1 '\t' $4 '\t' $5 '\t' 
>> $6;}'",nil];
>
> You have to pass each word as a separate string:
>
> arrayWithObjects: @"-c", @"/bin/df", @"-k", @"|", @"/usr/bin/grep", etc.

Normally you'd be correct, but in this case he would need to pass the
whole thing as a single argument to the '-c' flag of sh (you'd quote
it if you were actually in the shell).
___

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

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

2010-05-18 Thread Stephen J. Butler
On Tue, May 18, 2010 at 2:33 PM, appledev  wrote:
> I dont want to use a call to a bash script, because of sneaking in bad 
> commands.
> But how should I handle this?

That's only a real concern when you put user supplied data into the
command you're running. But I don't see you doing that here... you're
just using bash to parse the otput of some unix command.

> Does someone has any advice?

Depending on what information you need, I'd use [NSWorkspace
mountedLocalVolumePaths] and then [NSFileManager
attributesOfFileSystemForPath:error:].
___

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

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

2010-05-18 Thread Quincey Morris
On May 18, 2010, at 12:02, Richard Somers wrote:

> Foo is an int.

 If you want an answer, you're going to have to be a bit more forthcoming 
with information.

Is "foo" an instance variable or a property? If instance variable, what's the 
value of accessInstanceVariablesDirectly for its class? If a property, is there 
an @property declaration, and how are its getter and setter defined?

> Does not work means foo is never updated with the value in the user defaults.

Have you verified whether setFoo: is never called, or whether it's called with 
the wrong value? Is the setter called when you subsequently change the user 
default value that foo is bound to? How do you know that the user default value 
is correct? Just knowing that foo has the wrong value at some point isn't much 
help in tracking down the problem.

___

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

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

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

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


Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Eric Schlegel

On May 18, 2010, at 12:30 PM, Laurent Daudelin wrote:

> Wow! I was not aware of that! Is that supported on 10.5 too?


From NSMenuItem.h:

#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
- (void)setAlternate:(BOOL)isAlternate;
- (BOOL)isAlternate;
#endif

-eric

___

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

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

2010-05-18 Thread Rick Genter
On May 18, 2010, at 12:33 PM, appledev wrote:

> I have to run the following and similar commands using NSTask.
> 
> df -k | grep  /dev/ |awk '{print $1 "\t" $4 "\t" $5 "\t" $6;}'
> 
> I got so far.
> 
> NSTask *task;
>task = [[NSTask alloc] init];
>[task setLaunchPath: @"/bin/sh"];
>   
>NSArray *arguments;
>arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| /usr/bin/grep 
> /dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil];
>   // arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k", @"| 
> /usr/bin/grep /dev/ | /usr/bin/awk '{print $1 '\t' $4 '\t' $5 '\t' 
> $6;}'",nil];

You have to pass each word as a separate string:

arrayWithObjects: @"-c", @"/bin/df", @"-k", @"|", @"/usr/bin/grep", etc.

--
Rick Genter
rick.gen...@gmail.com

___

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

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

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

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


NSTask and piped commands

2010-05-18 Thread appledev
I have to run the following and similar commands using NSTask.

df -k | grep  /dev/ |awk '{print $1 "\t" $4 "\t" $5 "\t" $6;}'

I got so far.

NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sh"];

NSArray *arguments;
arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k| /usr/bin/grep 
/dev/ | /usr/bin/awk '{print $1 $4 $5 $6;}'",nil];
// arguments = [NSArray arrayWithObjects: @"-c", @"/bin/df -k", @"| 
/usr/bin/grep /dev/ | /usr/bin/awk '{print $1 '\t' $4 '\t' $5 '\t' $6;}'",nil];
NSLog ( @"%@", arguments );
[task setArguments: arguments];

NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];

[task launch];

[task waitUntilExit];

NSData *data;
result = [file readDataToEndOfFile];
NSString *string;
string = [[NSString alloc] initWithData: result encoding: 
NSUTF8StringEncoding];

I dont want to use a call to a bash script, because of sneaking in bad commands.
But how should I handle this?
Does someone has any advice?

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

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


Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Laurent Daudelin
On May 18, 2010, at 12:07, Eric Schlegel wrote:

> 
> On May 18, 2010, at 12:05 PM, Laurent Daudelin wrote:
> 
>> Well, I'd like to track the option key down when a menu is opened so that I 
>> can change one of the menu item title dynamically.
> 
> I was hoping you'd say that. :) NSMenuItem already has built-in support for 
> this. What you need to do is create two separate menu items and mark them as 
> being alternates of each other (this can be done in IB or with -[NSMenuItem 
> setAlternate:]). One menu item's modifiers should include the option key and 
> the other should not. The menu system will then automatically display the 
> correct menu item depending on whether the user is pressing the option key.
> 
> -eric

Wow! I was not aware of that! Is that supported on 10.5 too?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

Please do not post 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 I can't see my localized nib?

2010-05-18 Thread Frédéric Testuz
Le 18 mai 2010 à 18:28, Joanna Carter a écrit :

> Hi Gustavo
> 
>> In this case.. is tehre anyway to let teh user choose what lang to use?.. I 
>> mean if I localize my app, but the user has no localization either, how to 
>> make the app run in a given language (i.e sk)?
> 
> The only way I can think of is to delete the other localizations from the 
> bundle. Maybe someone else knows better :-)

You can launch the application with AppleLanguages in the arguments or in the 
app defaults.

See :



and



Frédéric___

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

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

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

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


Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Dave DeLong
Sounds to me like you want to investigate NSMenuItem's setAlternate: method.

I answered a StackOverflow question about this recently, so I'll just link to 
that post instead of typing everything again.  :)

http://stackoverflow.com/questions/2808016#2808168

Cheers,

Dave

On May 18, 2010, at 1:05 PM, Laurent Daudelin wrote:

> On May 18, 2010, at 11:57, Eric Schlegel wrote:
> 
>> 
>> On May 18, 2010, at 11:35 AM, Laurent Daudelin wrote:
>> 
>>> Thanks, Nick. That works. But now I realize I would need something a little 
>>> more dynamic. I see that NSResponder has "flagsChanged:" when a modifier 
>>> flag changes but since NSMenu is not a subclass of NSResponder, I'm not 
>>> sure how to detect this once the menu is pulled down. Should I subclass my 
>>> main window to detect it?
>> 
>> Once the menu is pulled down, the Menu Manager is running a nested event 
>> loop to track user input, so no NSEvents will be sent during that time 
>> anyways.
>> 
>> Can you tell us what exactly you're trying to accomplish?
>> 
>> -eric
> 
> Well, I'd like to track the option key down when a menu is opened so that I 
> can change one of the menu item title dynamically.
> 
> -Laurent.
> -- 
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin   
> http://nemesys.dyndns.org
> Logiciels Nemesys Software
> laurent.daude...@gmail.com
> Photo Gallery Store: 
> http://laurentdaudelin.shutterbugstorefront.com/g/galleries
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/davedelong%40me.com
> 
> This email sent to davedel...@me.com



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Eric Schlegel

On May 18, 2010, at 12:05 PM, Laurent Daudelin wrote:

> Well, I'd like to track the option key down when a menu is opened so that I 
> can change one of the menu item title dynamically.

I was hoping you'd say that. :) NSMenuItem already has built-in support for 
this. What you need to do is create two separate menu items and mark them as 
being alternates of each other (this can be done in IB or with -[NSMenuItem 
setAlternate:]). One menu item's modifiers should include the option key and 
the other should not. The menu system will then automatically display the 
correct menu item depending on whether the user is pressing the option key.

-eric

___

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

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

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

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


Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Laurent Daudelin
On May 18, 2010, at 11:57, Eric Schlegel wrote:

> 
> On May 18, 2010, at 11:35 AM, Laurent Daudelin wrote:
> 
>> Thanks, Nick. That works. But now I realize I would need something a little 
>> more dynamic. I see that NSResponder has "flagsChanged:" when a modifier 
>> flag changes but since NSMenu is not a subclass of NSResponder, I'm not sure 
>> how to detect this once the menu is pulled down. Should I subclass my main 
>> window to detect it?
> 
> Once the menu is pulled down, the Menu Manager is running a nested event loop 
> to track user input, so no NSEvents will be sent during that time anyways.
> 
> Can you tell us what exactly you're trying to accomplish?
> 
> -eric

Well, I'd like to track the option key down when a menu is opened so that I can 
change one of the menu item title dynamically.

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

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

2010-05-18 Thread Richard Somers

On May 18, 2010, at 10:04 AM, Quincey Morris wrote:


What is foo?

What does "not work" mean?


Foo is an int.

Does not work means foo is never updated with the value in the user  
defaults.


On May 18, 2010, at 10:21 AM, Chaitanya Pandit wrote:


Are you exposing the binding first?


No, but I agree with Kyle Sluder that this is not relevant.

--Richard

___

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

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


[iPhone] How to add a text field like that scales with return key like in iPhone Messages

2010-05-18 Thread Tharindu Madushanka
Hi,

I want to add a text field that will scale down when user presses the Return
key. mean time the background view will scale up same as how Messages iPhone
application do it. I have currently only a single line text field, on which
when i type more the font size gets decreased.

Could someone give me the idea of how i can implement that.

Thanks

Tharindu
___

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

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

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

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


Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Eric Schlegel

On May 18, 2010, at 11:35 AM, Laurent Daudelin wrote:

> Thanks, Nick. That works. But now I realize I would need something a little 
> more dynamic. I see that NSResponder has "flagsChanged:" when a modifier flag 
> changes but since NSMenu is not a subclass of NSResponder, I'm not sure how 
> to detect this once the menu is pulled down. Should I subclass my main window 
> to detect it?

Once the menu is pulled down, the Menu Manager is running a nested event loop 
to track user input, so no NSEvents will be sent during that time anyways.

Can you tell us what exactly you're trying to accomplish?

-eric

___

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

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

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

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


Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Laurent Daudelin
On May 18, 2010, at 10:59, Nick Zitzmann wrote:

> 
> On May 18, 2010, at 11:38 AM, Laurent Daudelin wrote:
> 
>> What's the best way to detect if a modifier key is held down when the user 
>> click to open a menu?
> 
> [[NSApp currentEvent] modifierFlags] ought to work...
> 
> Nick Zitzmann
> 
> 

Thanks, Nick. That works. But now I realize I would need something a little 
more dynamic. I see that NSResponder has "flagsChanged:" when a modifier flag 
changes but since NSMenu is not a subclass of NSResponder, I'm not sure how to 
detect this once the menu is pulled down. Should I subclass my main window to 
detect it?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

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

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

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


Re: (solved?) baseURL problem with +fileURLWithPath:

2010-05-18 Thread Robert Monaghan
Interesting.. The source of this path is from Final Cut Pro. I can't say how 
they come up with the path.
I will ping some people and find out.

bob.

On May 18, 2010, at 8:01 PM, John Joyce wrote:

> 
> On May 18, 2010, at 12:39 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
>> Content-Type: text/plain; charset=us-ascii
>> 
>> First, the first 2 characters need to be // and not / for it to be a valid 
>> resource specifier.  The 10.6 Overview states it will fail to create a 
>> NSURL.  Look at the class reference.  Why the base is set to your binary 
>> maybe just a bug in 10.5.  So you don't go nuts, just temp fix the string 
>> and then execute your code to see if the originating pseudo URL is your prob.
>> 
>> -Tony
> 
> Yes, the resource specifier should be  protocol://pathtoresource
> a file URL usesfile://path
> a path to a file always becomes absolute here.
> / is root directory of the volume in a file path in  unix
> thus, it should have the following appearance: (3 slashes after the colon)
> file:///absolute/path/to/file
> 
___

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

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

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

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


Re: Detecting modifier key down when opening a menu?

2010-05-18 Thread Nick Zitzmann

On May 18, 2010, at 11:38 AM, Laurent Daudelin wrote:

> What's the best way to detect if a modifier key is held down when the user 
> click to open a menu?

[[NSApp currentEvent] modifierFlags] ought to work...

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

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


Re: (solved?) baseURL problem with +fileURLWithPath:

2010-05-18 Thread John Joyce

On May 18, 2010, at 12:39 PM, cocoa-dev-requ...@lists.apple.com wrote:

> Content-Type: text/plain; charset=us-ascii
> 
> First, the first 2 characters need to be // and not / for it to be a valid 
> resource specifier.  The 10.6 Overview states it will fail to create a NSURL. 
>  Look at the class reference.  Why the base is set to your binary maybe just 
> a bug in 10.5.  So you don't go nuts, just temp fix the string and then 
> execute your code to see if the originating pseudo URL is your prob.
> 
> -Tony

Yes, the resource specifier should be  protocol://pathtoresource
 a file URL usesfile://path
 a path to a file always becomes absolute here.
 / is root directory of the volume in a file path in  unix
 thus, it should have the following appearance: (3 slashes after the colon)
 file:///absolute/path/to/file

You can quickly test such file paths for validity in Safari, they should open 
the resource or give an error there.
paste this into Safari's address bar and press enter/return:
file:///Users/

Then try this:
file:///Applications/Safari.app/Contents/Resources 

As you can see this should work within a bundle as well.
Safari is probably handing this off to the OS and doing basically what the 
command line does with the tool named open
If your resource is not revealed by the OS in some manner here then it is 
likely not available via NSURL or it is a malformed path.

[to OP] BTW,  as JOAR said, you were simply not using the API correctly. Please 
do not whine (as in the original post) as this is not 
helpful.___

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

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


Detecting modifier key down when opening a menu?

2010-05-18 Thread Laurent Daudelin
What's the best way to detect if a modifier key is held down when the user 
click to open a menu?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

Please do not post 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: Cancelling a loading loop in order to load something else

2010-05-18 Thread Keith Blount
Hi Kyle,

Many thanks for your reply, much appreciated. I guess it's finally time to get 
my hands dirty and learn how to use threads properly, then. :) (Although I was 
under the impression that working with NSAttributedStrings wasn't thread-safe 
according to other mail list postings. I could be wrong, though, given that I 
have managed to get away with barely touching threads thus far, and I'm not 
sure if that would include just loading an attributed string from a file.) I do 
need to stay 10.4-compatible which limits my use of the newer threading 
methods, although I suppose I could optimise for 10.6 so that users get the 
benefits of having the latest OS.

As for my use of a modal dialogue, sorry, I should have been more clear. The 
only places I use anything like that are for loading panels (import/export); it 
was merely my first resort given that I wasn't sure of the correct approach.

So, if I understand correctly, a threaded approach would go something like this:

• The user selects some documents.
• A "loading" progress indicator appears in the view where the text will be 
shown once ready.
• A separate thread is spawned to load all of those documents into various 
attributed strings and then into one long text storage.
• If the user selects something else, the other thread is cancelled.
• When the loading thread is completed, it returns each of the individual 
attributed strings that were loaded from file and the main text storage (or 
perhaps each attributed string one at a time) to the main thread so that I can 
load them.

If anyone knows of any good tutorials on threading for this sort of thing, I'd 
be very grateful for links, otherwise I'll be off to the Apple docs and 
CocoaDevCentral etc forthwith (I know there's a good chapter on threads in my 
Anguish/Buck/Yackman book, but that's now out of date for the newer methods).

Thanks again and all the best,
Keith


- Original Message 
From: Kyle Sluder 
To: Keith Blount 
Cc: "cocoa-dev@lists.apple.com" 
Sent: Tue, May 18, 2010 5:36:58 PM
Subject: Re: Cancelling a loading loop in order to load something else

On May 18, 2010, at 8:07 AM, Keith Blount  wrote:

> Should I forge ahead with trying to get a modal session working for this, or 
> is there a better solution I'm missing?

Perform the loading asynchronously or on a background thread. With 10.6, you 
could enqueue a block on a background queue for each file that needs to be 
loaded. Then you never have to block the main thread. It also questions your 
use of a modal dialog, but perhaps there are good UX reasons for that.

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

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


Re: Notifications on main thread

2010-05-18 Thread Jean-Daniel Dupas

Le 18 mai 2010 à 16:34, Jonny Taylor a écrit :

> Hi all,
> 
> I have been programming on the mac for many years but have only just started 
> trying to get the hang of cocoa. I have a particular question about 
> NSNotification that I hope somebody will be able to help with.
> 
> My code works with a firewire video camera, and receives callbacks from the 
> camera driver when a new video frame is received. Whenever this occurs, the 
> UI needs to be updated to display the latest video frame. The UI update must 
> run on the main thread - the callback thread is not a suitable place to do 
> the update. Furthermore I would like to use NSPostWhenIdle and coalescing - 
> if several new frames arrive between updates then we only need to draw the 
> most recent.
> 
> I am not sure how I should be achieving this.
> - I can call enqueueNotification on the default queue, but this will never 
> run since the callback thread is not running a CFRunLoop, and is not the 
> thread I wanted it to run on anyway.
> - I could try acquiring the NSNotificationQueue for the main thread, but 
> there does not appear to be a standard way of doing that. I have seen this 
> suggested as a strategy elsewhere, but I think I have also read that one is 
> not meant to post to queues other than that of the current thread (not sure 
> why...).

Because NSNotificationQueue is explicitly documented as non thread safe:

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html



-- Jean-Daniel




___

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

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

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

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


Re: (solved?) baseURL problem with +fileURLWithPath:

2010-05-18 Thread Tony Romano
First, the first 2 characters need to be // and not / for it to be a valid 
resource specifier.  The 10.6 Overview states it will fail to create a NSURL.  
Look at the class reference.  Why the base is set to your binary maybe just a 
bug in 10.5.  So you don't go nuts, just temp fix the string and then execute 
your code to see if the originating pseudo URL is your prob.

-Tony


On May 18, 2010, at 5:51 AM, Robert Monaghan wrote:

> Ok, I am doing this now, which *seems* to work.
> NSURL *url = [NSURL URLWithString:[[pathurlArray objectAtIndex:0] 
> stringValue] relativeToURL:nil];
> 
> bob..
> 
> 
> 
> On May 18, 2010, at 2:20 PM, Robert Monaghan wrote:
> 
>> The path from [[pathurlArray objectAtIndex:0] stringValue] is going into the 
>> NSURL properly.
>> This doesn't appear to be a problem with retaining the source NSArray object.
>> 
>> The base URL, however is being populated with the path to my binary. I am 
>> trying to figure out how to set the baseURL to nil.
>> If I print a description, I get:
>> 
>> {type = 15, string = 
>> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov,
>>  encoding = 134217984
>>  base = {type = 0, string = 
>> /Users/bob/Development/GT_Dig/GT_Cons/build/Debug/, encoding = 134217984, 
>> base = (null)}}
>> 
>> bob.
>> 
>> On May 18, 2010, at 2:12 PM, Abhinay Kartik Reddyreddy wrote:
>> 
>>> 
>>> On May 18, 2010, at 7:52 AM, Robert Monaghan wrote:
>>> 
 Hi Mike,
 
 This is pretty trivial.. I have a string that is coming from an FCP XML 
 file. The string looks like this:
 file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
 
 I then pass the string to an NSURL object using: (Yes, I know I can do a 
 "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
 NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
 objectAtIndex:0] stringValue]] autorelease];
 
>>> 
>>> How about if you copy [[pathurlArray objectAtIndex:0] stringValue]  into a 
>>> NSString, retain it and create a NSURL instead of creating from 
>>> pathurlArray directly...??
>>> 
 Then, I try to get an NSString object by doing:
 [url path]
 
>>> 
>>> What would be the value in [[pathurlArray objectAtIndex:0] stringValue] at 
>>> this point...?? May be the pathurlArray is Auto released before you create 
>>> the NSURL...?? Just a guess
>>> 
 This is where things go wildly wrong.. the NSString value ends up being a 
 path to my binary.
 
 
 bob.
 
 
 On May 18, 2010, at 12:55 PM, Mike Abdullah wrote:
 
> Show us some code.
> 
> On 18 May 2010, at 09:49, Robert Monaghan wrote:
> 
>> Hi Everyone..
>> 
>> I am loosing my mind with NSURL's initFileURLWithPath. (Trying to build 
>> a 10.5 app.. btw)
>> 
>> If I create a NSURL object with a local file path, everything looks as 
>> it should, when stepping through the code with the debugger.
>> However, when I use "[myURL path]" in my code, I get a path to my binary 
>> instead of the path that is placed into NSURL object.
>> After doing some reading, this looks as if my local file path is being 
>> set as the "Relative" path, and the binary application is set as
>> the "BaseURL".
>> 
>> Can someone (preferably from Apple) explain why this is broken with file 
>> paths?
>> -- Yes.. it is broken, as there is no way to set the baseURL, nor is 
>> there a way to set my local file path as the baseURL.
>> --- I used absoluteURL, but that only returns the binary path.
>> 
>> I hope I don't have to remove these NSURL objects and replace them with 
>> NSStrings..
>> what a pain in the a..
>> 
>> bob.
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/cocoadev%40mikeabdullah.net
>> 
>> This email sent to cocoa...@mikeabdullah.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:
 http://lists.apple.com/mailman/options/cocoa-dev/karthikreddy09%40gmail.com
 
 This email sent to karthikredd...@gmail.com
>>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact t

Re: Notifications on main thread

2010-05-18 Thread Michael Ash
On Tue, May 18, 2010 at 12:58 PM, Nick Zitzmann  wrote:
>
> On May 18, 2010, at 8:34 AM, Jonny Taylor wrote:
>
>> - I could try acquiring the NSNotificationQueue for the main thread, but 
>> there does not appear to be a standard way of doing that. I have seen this 
>> suggested as a strategy elsewhere, but I think I have also read that one is 
>> not meant to post to queues other than that of the current thread (not sure 
>> why...).
> [...]
>> I feel there must be a simple way of doing what I want - can anybody advise?
>
> There is a way to do this. You need to set up the enqueue message in an 
> NSInvocation, have it retain the arguments, and then call the invocation's 
> -performSelectorOnMainThread:... method to invoke the invocation on the main 
> thread. This works any time you need to call something on the main thread, 
> but you need to set more than one argument, or the method has arguments that 
> take primitives instead of objects.

Note that if you're targeting 10.6 then you can do it MUCH more easily
by using blocks and either NSOperationQueue or GCD:

// NSOpQ
[[NSOperationQueue mainQueue] addOperationWithBlock: ^{ /* post your
notification here */ }];

// GCD
dispatch_async(dispatch_get_main_queue(), ^{ /* post your notification
here */ });

And if you need it, you can also use dispatch_sync in place of
dispatch_async in order to have the calling code block until the
notification has finished posting. This is also possible with
NSOperationQueue, but requires substantially more code, so the GCD
route is probably better. (You should try to avoid sync operations
when multithreading when possible, but sometimes you need it.)

Mike
___

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

Please do not post 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: My program causes MacBook Pro to use NVidia graphics processor

2010-05-18 Thread Michael Diehr
On May 17, 2010, at 6:26 PM, Michael Diehr wrote:

> Update: it appears as if instantiating a dummy NSOpenGLView in my master 
> process helps the issue.
> 
> I'm not clear whether I actually need to go so far as to create the 
> NSOpenGLView and add it as a subview, or if simply linking with the OpenGL 
> framework is sufficient.

I did more testing, and indeed I do need to instantiate the NSOpenGLView -- 
simply linking to the OpenGL framework by itself doesn't 
work___

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

Please do not post 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: My program causes MacBook Pro to use NVidia graphics

2010-05-18 Thread Keith Blount
Hi Nick, many thanks for the clarification. That explains the OpenGL inclusion 
then, as I include Quartz for the PDFKit.
Thanks again and all the best,
Keith

P.S. Apologies as I think I may have previously sent a blank reply.


- Original Message 
From: Nick Zitzmann 
To: Keith Blount 
Cc: cocoa-dev@lists.apple.com
Sent: Tue, May 18, 2010 5:16:31 PM
Subject: Re: My program causes MacBook Pro to use NVidia graphics


On May 18, 2010, at 3:28 AM, Keith Blount wrote:

> I'm not explicitly linking against the OpenGL framework, though - does this 
> mean that another framework I am linking against is invoking it? (I link 
> against the QuickLook, AddressBook, Carbon, QTKit,
> QuickTime, Quartz, QuartzCore, WebKit and SystemConfiguration frameworks.)

Yes. The ImageKit framework, which is part of the Quartz framework, links 
against OpenGL because several of the ImageKit views use OpenGL for drawing. 
QuartzCore also uses OpenGL, presumably for CoreAnimation. You can see this for 
yourself by using otool.

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

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


Re: Notifications on main thread

2010-05-18 Thread Nick Zitzmann

On May 18, 2010, at 8:34 AM, Jonny Taylor wrote:

> - I could try acquiring the NSNotificationQueue for the main thread, but 
> there does not appear to be a standard way of doing that. I have seen this 
> suggested as a strategy elsewhere, but I think I have also read that one is 
> not meant to post to queues other than that of the current thread (not sure 
> why...).
[...]
> I feel there must be a simple way of doing what I want - can anybody advise?

There is a way to do this. You need to set up the enqueue message in an 
NSInvocation, have it retain the arguments, and then call the invocation's 
-performSelectorOnMainThread:... method to invoke the invocation on the main 
thread. This works any time you need to call something on the main thread, but 
you need to set more than one argument, or the method has arguments that take 
primitives instead of objects.

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

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


Notifications on main thread

2010-05-18 Thread Jonny Taylor
Hi all,

I have been programming on the mac for many years but have only just started 
trying to get the hang of cocoa. I have a particular question about 
NSNotification that I hope somebody will be able to help with.

My code works with a firewire video camera, and receives callbacks from the 
camera driver when a new video frame is received. Whenever this occurs, the UI 
needs to be updated to display the latest video frame. The UI update must run 
on the main thread - the callback thread is not a suitable place to do the 
update. Furthermore I would like to use NSPostWhenIdle and coalescing - if 
several new frames arrive between updates then we only need to draw the most 
recent.

I am not sure how I should be achieving this.
- I can call enqueueNotification on the default queue, but this will never run 
since the callback thread is not running a CFRunLoop, and is not the thread I 
wanted it to run on anyway.
- I could try acquiring the NSNotificationQueue for the main thread, but there 
does not appear to be a standard way of doing that. I have seen this suggested 
as a strategy elsewhere, but I think I have also read that one is not meant to 
post to queues other than that of the current thread (not sure why...).
- I could try using NSDistributedNotificationCenter, but that seems overkill 
for what I want in terms of performance and its inherent limitations.

I feel there must be a simple way of doing what I want - can anybody advise?

Thanks in advance
Jonny


___

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

Please do not post 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: Cancelling a loading loop in order to load something else

2010-05-18 Thread Kyle Sluder

On May 18, 2010, at 8:07 AM, Keith Blount  wrote:

Should I forge ahead with trying to get a modal session working for  
this, or is there a better solution I'm missing?


Perform the loading asynchronously or on a background thread. With  
10.6, you could enqueue a block on a background queue for each file  
that needs to be loaded. Then you never have to block the main thread.  
It also questions your use of a modal dialog, but perhaps there are  
good UX reasons for that.


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

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


Re: Regarding MVC design pattern

2010-05-18 Thread Uli Kusterer
On May 18, 2010, at 1:20 PM, Sai wrote:
> Anyway, why I should retain that?

 Because otherwise it will get autoreleased, but your instance variable will 
still contain its address, and the next time you try to use it via the instance 
variable, you will try to talk with random memory at that address, which is a 
Bad Idea(tm). It may still look like the object that was last there, it may 
look like a completely different object, or it may have been overwritten by 
someone in the meantime.

> Will it be released by "somebody"?

 Hopefully by your dealloc method.

 This behaviour would only be different if you were using the garbage collector.

 If all of this is new to you, you should really try to get a good book about 
the basics of Cocoa objects and memory management.

-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."



___

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

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

2010-05-18 Thread Kyle Sluder
On May 18, 2010, at 9:21 AM, Chaitanya Pandit   
wrote:



Are you exposing the binding first?


This is completely unnecessary.

--Kyle Sluder



+ (void)exposeBinding:(NSString *)binding

Thanks,

Chaitanya Pandit
Chief Architect
Expersis Software Inc.

On May 18, 2010, at 7:47 PM, Richard Somers wrote:

I have an issue that has me absolutely stumped. I have a custom  
view using a custom layer. When  
'bind:toObject:withKeyPath:options:' is called after 'setView' the  
binding works. When it is called before 'setView' the binding does  
not work.


// MyCustomView (this version works)
- (void)awakeFromNib
{
   layer = [[MyCustomLayer alloc] init];
   [layer setView:self];
   [layer bindFoo]; // bind works
   ...
}

// MyCustomView (this version does not work)
- (void)awakeFromNib
{
   layer = [[MyCustomLayer alloc] init];
   [layer bindFoo]; // bind does not work
   [layer setView:self];
   ...
}

// MyCustomOpenGLLayer
@property (retain) MyCustomView *view;
@synthesize view;

- (void)bindFoo
{
   [self bind:@"foo"
 toObject:[NSUserDefaultsController sharedUserDefaultsController]
  withKeyPath:@"values.foo"
  options:nil];
}

Any ideas why the first version works but not the second?

--Richard


___

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

Please do not post 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 I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

> In this case.. is tehre anyway to let teh user choose what lang to use?.. I 
> mean if I localize my app, but the user has no localization either, how to 
> make the app run in a given language (i.e sk)?

The only way I can think of is to delete the other localizations from the 
bundle. Maybe someone else knows better :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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

Please do not post 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: Regarding MVC design pattern

2010-05-18 Thread Kyle Sluder

On May 18, 2010, at 4:20 AM, Sai  wrote:


Hi all,

Thanks for your reply. I didn't retain that, I will try that as soon  
as I

get home.
Anyway, why I should retain that? Will it be released by "somebody"?


Re-read the Memory Management Programming Guide until you know the  
rules backwards and forwards. +dictionaryWithObjects:forKeys: doesn't  
start with "alloc," "new," or "copy," so you don't own its return value.



Can
anyone tell me the whole process and what's going on please? I want  
to know

what happened. Thanks a lot.


This shouldnt be necessary once you reread the documentation. But in  
order to do that, you would need to post your code in context, which  
you should always do for every question you ask. Out of context, what  
you posted is neither wrong nor right.


--Kyle Sluder




On Tue, May 18, 2010 at 7:07 PM, Jack Nutting   
wrote:



On Tue, May 18, 2010 at 12:40 PM, Sai  wrote:
However, I declare a NSDictionary instance variable in my model  
object.

This

NSDictionary instance
store some data I need. And I will create this NSDictionary  
instance by

invoking:
[NSDictionary dictionaryWithObjects:names forKeys:keys]


Are you retaining that?

- (id)init {
if (self = [super init]) {
  // assuming you have an ivar called "dict", this will lead to the
problem you define:
  dict = [NSDictionary dictionaryWithObjects:names forKeys:keys];
  // but this should work:
  dict = [[NSDictionary dictionaryWithObjects:names forKeys:keys]  
retain];

 }
}

--
// jack
// http://nuthole.com
// http://learncocoa.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:
http://lists.apple.com/mailman/options/cocoa-dev/kyle.sluder%40gmail.com

This email sent to kyle.slu...@gmail.com

___

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

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

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

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


Re: Programmatic Binding

2010-05-18 Thread Chaitanya Pandit
Are you exposing the binding first?

+ (void)exposeBinding:(NSString *)binding

Thanks,

Chaitanya Pandit
Chief Architect
Expersis Software Inc.

On May 18, 2010, at 7:47 PM, Richard Somers wrote:

> I have an issue that has me absolutely stumped. I have a custom view using a 
> custom layer. When 'bind:toObject:withKeyPath:options:' is called after 
> 'setView' the binding works. When it is called before 'setView' the binding 
> does not work.
> 
> // MyCustomView (this version works)
> - (void)awakeFromNib
> {
> layer = [[MyCustomLayer alloc] init];
> [layer setView:self];
> [layer bindFoo]; // bind works
> ...
> }
> 
> // MyCustomView (this version does not work)
> - (void)awakeFromNib
> {
> layer = [[MyCustomLayer alloc] init];
> [layer bindFoo]; // bind does not work
> [layer setView:self];
> ...
> }
> 
> // MyCustomOpenGLLayer
> @property (retain) MyCustomView *view;
> @synthesize view;
> 
> - (void)bindFoo
> {
> [self bind:@"foo"
>   toObject:[NSUserDefaultsController sharedUserDefaultsController]
>withKeyPath:@"values.foo"
>options:nil];
> }
> 
> Any ideas why the first version works but not the second?
> 
> --Richard
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/chaitanya%40expersis.com
> 
> This email sent to chaita...@expersis.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: My program causes MacBook Pro to use NVidia graphics

2010-05-18 Thread Nick Zitzmann

On May 18, 2010, at 3:28 AM, Keith Blount wrote:

> I'm not explicitly linking against the OpenGL framework, though - does this 
> mean that another framework I am linking against is invoking it? (I link 
> against the QuickLook, AddressBook, Carbon, QTKit,
> QuickTime, Quartz, QuartzCore, WebKit and SystemConfiguration frameworks.)

Yes. The ImageKit framework, which is part of the Quartz framework, links 
against OpenGL because several of the ImageKit views use OpenGL for drawing. 
QuartzCore also uses OpenGL, presumably for CoreAnimation. You can see this for 
yourself by using otool.

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

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


Re: Programmatic Binding

2010-05-18 Thread Quincey Morris
On May 18, 2010, at 07:17, Richard Somers wrote:

> I have an issue that has me absolutely stumped. I have a custom view using a 
> custom layer. When 'bind:toObject:withKeyPath:options:' is called after 
> 'setView' the binding works. When it is called before 'setView' the binding 
> does not work.

...

> - (void)bindFoo
> {
> [self bind:@"foo"
>   toObject:[NSUserDefaultsController sharedUserDefaultsController]
>withKeyPath:@"values.foo"
>options:nil];
> }

What is foo?

What does "not work" 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Why I can't see my localized nib?

2010-05-18 Thread Gustavo Pizano
No problem...

In this case.. is tehre anyway to let teh user choose what lang to use?.. I 
mean if I localize my app, but the user has no localization either, how to make 
the app run in a given language (i.e sk)?

G.
PS:
thanks for the help tough

On 18.5.2010, at 17:46, Joanna Carter wrote:

> Hi Gustavo
> 
>> Joanna hello. here is the app.
> 
> I cannot get the Slovak localisation to work either. But, then I read that 
> the localisation is not included in Snow Leopard by default and I don't want 
> to have to buy the licence for it.
> 
> Sorry about that.
> 
> Joanna
> 
> --
> Joanna Carter
> Carter Consulting
> 

___

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

Please do not post 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 I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

> Joanna hello. here is the app.

I cannot get the Slovak localisation to work either. But, then I read that the 
localisation is not included in Snow Leopard by default and I don't want to 
have to buy the licence for it.

Sorry about that.

Joanna

--
Joanna Carter
Carter Consulting

___

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

Please do not post 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: My program causes MacBook Pro to use NVidia graphics processor

2010-05-18 Thread Michael Diehr
On May 17, 2010, at 6:41 PM, Dave Keck wrote:

> The user's Energy Saver settings affects which card is used (better
> battery life vs. higher performance.) Not sure if that helps you
> though, since changing the value on my system requires logging out.

According to this:
  
http://codykrieger.com/blog/2010/05/gfxcardstatus-and-2009-macbook-pros-with-nvidia-94009600-gpus/

you *can* switch the 9600/9400 live without logging out/back in -- though one 
expects that Apple did not enable this feature for good reason...


___

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

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

2010-05-18 Thread Richard Somers

On May 18, 2010, at 8:17 AM, Richard Somers wrote:


I have an issue that has me absolutely stumped.


Correction and additional information.

MyCustomOpenGLLayer should be MyCustomLayer.

MyCustomLayer does not implement 'bind:toObject:withKeyPath:options:'  
so the standard framework version of this method is used.


--Richard

___

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

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


Cancelling a loading loop in order to load something else

2010-05-18 Thread Keith Blount
Hi,

I'm having problems getting my head around something that is probably fairly 
basic, but I can't find any obvious examples to give me the clue I need (no 
doubt because I'm using the wrong search terms). Essentially I need to add to 
my app the ability for the user to cancel what could potentially be a long and 
intensive loading loop when the user clicks to load something else, but I'm 
having difficulties coming up with a solution that works for this particular 
situation. Usually for this sort of thing I use a modal session and check that 
-runModalSession: returns NSRunContinuesResponse inside the loop, to see if the 
user has cancelled and the loop should be exited. But this doesn't seem to work 
for what I'm trying to do right now (or at least my attempts so far have had 
poor results). It may be that a modal session is still the right approach, but 
before I spend another day trying to get it to work properly, I'd be grateful 
if anyone could let me know if
 I'm on the right tack or if I'm missing a better approach.

This is what I'm trying to do:

• In the source list of my app, the user can select multiple text documents.
• A loop is invoked in which each selected document gets loaded from a file on 
disk and combined into a single text storage, then displayed in a text view.
• There is the potential for hundreds of files to be loaded from file during 
this loop and combined into one text storage, which can take time. (A "loading" 
message gets shown while loading occurs.)
• During this loading, the user should be able to cancel the load by selecting 
other documents in the source list, and this is the refinement I'm trying to 
add at the moment and am finding difficult. The problem I'm having is that the 
same action that caused the loading loop should cancel it and set it up for a 
different load, if that makes sense.

In other words, what is the best way of doing the following:

• The user clicks on an item in the interface which calls method -foo:, which 
invokes a long loop that can potentially take a lot of time.
• The user clicks on another item in the interface which immediately cancels 
what -foo: is currently doing (causes it to exit its loop and return) so that 
it can call -foo: with new information to put through the loop without having 
to wait for the old loop to complete.

Pseudo code:

@implementation MyTableDelegate

- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
// To further confuse things we only load anything after a slight delay, so 
that using the arrow keys to navigate quickly through the
// table view won't be slowed down by loading every single text.

[[MyOtherController class] 
cancelPreviousPerformRequestsWithTarget:myController];
[myController performSelector:@selector(doSomethingWithObjects:) 
withObject:[myTableController selectedObjects] afterDelay:0.1];
}

@end

@implementation MyOtherController

- (void)doSomethingWithObjects:(NSArray *)someObjects
{
[self showLoadingProgressIndicator];
[self clearOutSomeOtherStuff];

NSEnumerator *e = [someObjects objectEnumerator];
id obj;
while (obj = [e nextObject])
{
NSAttributedString *text = [self loadTextFromFileForObject: obj];
[combinedText appendAttributedString:text];
}

[self loadText:text];
}

@end

So, in the pseudo code above, how could I make it so that the user could still 
click into the table view while -doSomethingWithObjects: is looping through the 
objects it has already been passed from the last table-click, and so that 
-tableViewSelectionWillChange: will cancel the current -doSomethingWithObjects: 
loop and immediately call -doSomethingWithObjects: again with a different 
array? (-doSomethingWithObjects: may be called from other areas of the 
interface, too, though - not just from the table view.)

I've tried creating a modal session at the beginning of the loop and calling 
through to cancel it from the -tableViewSelectionDidChange: method before 
calling -doSomethingWithObjects: with the new objects, but it seems flaky (it 
sort of works but then the interface seems to freeze a moment afterwards). 
Also, -tableViewSelectionDidChange: isn't the only place the loading method can 
get called from - that is, in the pseudo code above, -doSomethingWithObjects: 
could be called from various other places, too, so it's almost as if 
-doSomethingWithObjects: needs to cancel itself if called a second time (whilst 
allowing the user to click elsewhere in the interface rather than freezing 
everything).

Should I forge ahead with trying to get a modal session working for this, or is 
there a better solution I'm missing?

Any pointers to examples or links that I may have missed or other suggestions 
much appreciated.

Thanks and all the best,
Keith



___

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

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

Help/Unsu

Re: Blog post announcements

2010-05-18 Thread Bill Hernandez

On May 18, 2010, at 1:09 AM, Scott Anguish wrote:

> Hi Bill
> 
> I moderate the cocoa-dev list. I’m hoping you could do be a favor. Can you 
> pace yourself a bit on announcing your blog posts? Perhaps collect a few and 
> post them once a week?
> 
> I’ve had a few people poke me about it. I don’t want to discourage, just try 
> and cut down traffic.
> 
> Much appreciated. 
> 
> Scott

I am sorry Scott, in my exuberance to share what I've been learning, I din't 
realize that I was creating a problem, or that I was offending anyone. I am so 
sorry, I won't be making any further posts. 

Thank You for making me aware of the problem.

Sincerely,

Bill Hernandez
Plano, Texas___

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

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


Programmatic Binding

2010-05-18 Thread Richard Somers
I have an issue that has me absolutely stumped. I have a custom view  
using a custom layer. When 'bind:toObject:withKeyPath:options:' is  
called after 'setView' the binding works. When it is called before  
'setView' the binding does not work.


// MyCustomView (this version works)
- (void)awakeFromNib
{
 layer = [[MyCustomLayer alloc] init];
 [layer setView:self];
 [layer bindFoo]; // bind works
 ...
}

// MyCustomView (this version does not work)
- (void)awakeFromNib
{
 layer = [[MyCustomLayer alloc] init];
 [layer bindFoo]; // bind does not work
 [layer setView:self];
 ...
}

// MyCustomOpenGLLayer
@property (retain) MyCustomView *view;
@synthesize view;

- (void)bindFoo
{
 [self bind:@"foo"
   toObject:[NSUserDefaultsController sharedUserDefaultsController]
withKeyPath:@"values.foo"
options:nil];
}

Any ideas why the first version works but not the second?

--Richard

___

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

Please do not post 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: baseURL problem with +fileURLWithPath:

2010-05-18 Thread Joar Wingfors

On 18 maj 2010, at 04.52, Robert Monaghan wrote:

> This is pretty trivial.. I have a string that is coming from an FCP XML file. 
> The string looks like this:
> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
> 
> I then pass the string to an NSURL object using: (Yes, I know I can do a 
> "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
> NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
> objectAtIndex:0] stringValue]] autorelease];


You're doing it wrong...   ;-)

The "-initFileURLWithPath:" and "+fileURLWithPath:" methods takes a string 
containing a path (would have been "/Users/..." in your example above), not the 
file-URL representation of that path ("file:/localhost/Users/..." in your 
example above).

If you already have a string that contains a RFC 2396 compliant representation 
of a URL, you should be using the "init with string" style initializers to 
create the URL.


> Then, I try to get an NSString object by doing:
> [url path]
> 
> This is where things go wildly wrong.. the NSString value ends up being a 
> path to my binary.


The clue to this behavior can be found in the documentation for CFURL:

"If filePath is not absolute, the resulting URL will be considered relative to 
the current working directory (evaluated when this function is being invoked)."

Please file a bug report if you think that the documentation should be improved:




j o a r


___

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

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

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

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


Re: (solved?) baseURL problem with +fileURLWithPath:

2010-05-18 Thread Robert Monaghan
Ok, I am doing this now, which *seems* to work.
NSURL *url = [NSURL URLWithString:[[pathurlArray objectAtIndex:0] stringValue] 
relativeToURL:nil];

bob..



On May 18, 2010, at 2:20 PM, Robert Monaghan wrote:

> The path from [[pathurlArray objectAtIndex:0] stringValue] is going into the 
> NSURL properly.
> This doesn't appear to be a problem with retaining the source NSArray object.
> 
> The base URL, however is being populated with the path to my binary. I am 
> trying to figure out how to set the baseURL to nil.
> If I print a description, I get:
> 
> {type = 15, string = 
> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov,
>  encoding = 134217984
>   base = {type = 0, string = 
> /Users/bob/Development/GT_Dig/GT_Cons/build/Debug/, encoding = 134217984, 
> base = (null)}}
> 
> bob.
> 
> On May 18, 2010, at 2:12 PM, Abhinay Kartik Reddyreddy wrote:
> 
>> 
>> On May 18, 2010, at 7:52 AM, Robert Monaghan wrote:
>> 
>>> Hi Mike,
>>> 
>>> This is pretty trivial.. I have a string that is coming from an FCP XML 
>>> file. The string looks like this:
>>> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
>>> 
>>> I then pass the string to an NSURL object using: (Yes, I know I can do a 
>>> "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
>>> NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
>>> objectAtIndex:0] stringValue]] autorelease];
>>> 
>> 
>> How about if you copy [[pathurlArray objectAtIndex:0] stringValue]  into a 
>> NSString, retain it and create a NSURL instead of creating from pathurlArray 
>> directly...??
>> 
>>> Then, I try to get an NSString object by doing:
>>> [url path]
>>> 
>> 
>> What would be the value in [[pathurlArray objectAtIndex:0] stringValue] at 
>> this point...?? May be the pathurlArray is Auto released before you create 
>> the NSURL...?? Just a guess
>> 
>>> This is where things go wildly wrong.. the NSString value ends up being a 
>>> path to my binary.
>>> 
>>> 
>>> bob.
>>> 
>>> 
>>> On May 18, 2010, at 12:55 PM, Mike Abdullah wrote:
>>> 
 Show us some code.
 
 On 18 May 2010, at 09:49, Robert Monaghan wrote:
 
> Hi Everyone..
> 
> I am loosing my mind with NSURL's initFileURLWithPath. (Trying to build a 
> 10.5 app.. btw)
> 
> If I create a NSURL object with a local file path, everything looks as it 
> should, when stepping through the code with the debugger.
> However, when I use "[myURL path]" in my code, I get a path to my binary 
> instead of the path that is placed into NSURL object.
> After doing some reading, this looks as if my local file path is being 
> set as the "Relative" path, and the binary application is set as
> the "BaseURL".
> 
> Can someone (preferably from Apple) explain why this is broken with file 
> paths?
> -- Yes.. it is broken, as there is no way to set the baseURL, nor is 
> there a way to set my local file path as the baseURL.
> --- I used absoluteURL, but that only returns the binary path.
> 
> I hope I don't have to remove these NSURL objects and replace them with 
> NSStrings..
> what a pain in the a..
> 
> bob.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.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:
>>> http://lists.apple.com/mailman/options/cocoa-dev/karthikreddy09%40gmail.com
>>> 
>>> This email sent to karthikredd...@gmail.com
>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/bob%40gluetools.com
> 
> This email sent to b...@gluetools.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

Thi

Re: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

> Ok I tried again with French lang, run it and din't work, clean target and 
> rerun and it worked.. Now I made for sk_SK lang same procedure as before, 
> (changing the lang of the system) and it didn't work. I took the codes from 
> the ISO docs and when I open the xib of slovak lang it says 'slovensky" so 
> the code its being detected.
> 
> MMM now I wonder if I have the localization installed... 

If you can change the OS language to French and restart any of the Apple apps 
in French, then that doesn't sound likely.

Send me the project.

Joanna

--
Joanna Carter
Carter Consulting

___

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

Please do not post 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 I can't see my localized nib?

2010-05-18 Thread Gustavo Pizano
Joanna Hello.

Ok I tried again with French lang, run it and din't work, clean target and 
rerun and it worked.. Now I made for sk_SK lang same procedure as before, 
(changing the lang of the system) and it didn't work. I took the codes from the 
ISO docs and when I open the xib of slovak lang it says 'slovensky" so the code 
its being detected.  

MMM now I wonder if I have the localization installed... 

> In a test app I ran into the same problem. That changed after I connected the 
> menu command orderFrontStandardAboutPanel: - by default connected via the 
> File's Owner - to the overridden method in my class.

Im gonnna try this, wait.


mmm nop didn't work for the sk_SK

So I guess this aims to check the loc lang in the system.

G

On 18.5.2010, at 12:44, Joanna Carter wrote:

> Hi Gustavo
> 
>> I dunno about that.. I was just selecting French from the pop up list when I 
>> clicked the "Make localizable" button under info of the xib file, and then I 
>> put in the first position of the lang list under system preferences French 
>> language... re build re run and nothing, I logout and login again the system 
>> and all was in french (finder) but still when running I was seeing the 
>> English version of the xib. I tried also for another lang sk_SK (for 
>> Slovakia) and nothing also... 
>> 
>> 
>> Its wird, Im not localizing  my app yet, but Im getting ready for the task 
>> which will come very soonso thats why its urgent for me to at least make 
>> a test app localized.
> 
> Do you fancy sending me your test app? I run OS X in French all the time and 
> often localise from the default English to French.
> 
> Don't forget to clean out the Build folder before zipping and sending it :-)
> 
> Joanna
> 
> --
> Joanna Carter
> Carter Consulting
> 

___

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

Please do not post 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: baseURL problem with +fileURLWithPath:

2010-05-18 Thread Robert Monaghan
The path from [[pathurlArray objectAtIndex:0] stringValue] is going into the 
NSURL properly.
This doesn't appear to be a problem with retaining the source NSArray object.

The base URL, however is being populated with the path to my binary. I am 
trying to figure out how to set the baseURL to nil.
If I print a description, I get:

{type = 15, string = 
file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov,
 encoding = 134217984
base = {type = 0, string = 
/Users/bob/Development/GT_Dig/GT_Cons/build/Debug/, encoding = 134217984, base 
= (null)}}

bob.

On May 18, 2010, at 2:12 PM, Abhinay Kartik Reddyreddy wrote:

> 
> On May 18, 2010, at 7:52 AM, Robert Monaghan wrote:
> 
>> Hi Mike,
>> 
>> This is pretty trivial.. I have a string that is coming from an FCP XML 
>> file. The string looks like this:
>> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
>> 
>> I then pass the string to an NSURL object using: (Yes, I know I can do a 
>> "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
>> NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
>> objectAtIndex:0] stringValue]] autorelease];
>> 
> 
> How about if you copy [[pathurlArray objectAtIndex:0] stringValue]  into a 
> NSString, retain it and create a NSURL instead of creating from pathurlArray 
> directly...??
> 
>> Then, I try to get an NSString object by doing:
>> [url path]
>> 
> 
> What would be the value in [[pathurlArray objectAtIndex:0] stringValue] at 
> this point...?? May be the pathurlArray is Auto released before you create 
> the NSURL...?? Just a guess
> 
>> This is where things go wildly wrong.. the NSString value ends up being a 
>> path to my binary.
>> 
>> 
>> bob.
>> 
>> 
>> On May 18, 2010, at 12:55 PM, Mike Abdullah wrote:
>> 
>>> Show us some code.
>>> 
>>> On 18 May 2010, at 09:49, Robert Monaghan wrote:
>>> 
 Hi Everyone..
 
 I am loosing my mind with NSURL's initFileURLWithPath. (Trying to build a 
 10.5 app.. btw)
 
 If I create a NSURL object with a local file path, everything looks as it 
 should, when stepping through the code with the debugger.
 However, when I use "[myURL path]" in my code, I get a path to my binary 
 instead of the path that is placed into NSURL object.
 After doing some reading, this looks as if my local file path is being set 
 as the "Relative" path, and the binary application is set as
 the "BaseURL".
 
 Can someone (preferably from Apple) explain why this is broken with file 
 paths?
 -- Yes.. it is broken, as there is no way to set the baseURL, nor is there 
 a way to set my local file path as the baseURL.
 --- I used absoluteURL, but that only returns the binary path.
 
 I hope I don't have to remove these NSURL objects and replace them with 
 NSStrings..
 what a pain in the a..
 
 bob.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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:
>> http://lists.apple.com/mailman/options/cocoa-dev/karthikreddy09%40gmail.com
>> 
>> This email sent to karthikredd...@gmail.com
> 

___

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

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

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

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


Re: baseURL problem with +fileURLWithPath:

2010-05-18 Thread Abhinay Kartik Reddyreddy

On May 18, 2010, at 7:52 AM, Robert Monaghan wrote:

> Hi Mike,
> 
> This is pretty trivial.. I have a string that is coming from an FCP XML file. 
> The string looks like this:
> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
> 
> I then pass the string to an NSURL object using: (Yes, I know I can do a 
> "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
> NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
> objectAtIndex:0] stringValue]] autorelease];
> 

How about if you copy [[pathurlArray objectAtIndex:0] stringValue]  into a 
NSString, retain it and create a NSURL instead of creating from pathurlArray 
directly...??

> Then, I try to get an NSString object by doing:
> [url path]
> 

What would be the value in [[pathurlArray objectAtIndex:0] stringValue] at this 
point...?? May be the pathurlArray is Auto released before you create the 
NSURL...?? Just a guess

> This is where things go wildly wrong.. the NSString value ends up being a 
> path to my binary.
> 
> 
> bob.
> 
> 
> On May 18, 2010, at 12:55 PM, Mike Abdullah wrote:
> 
>> Show us some code.
>> 
>> On 18 May 2010, at 09:49, Robert Monaghan wrote:
>> 
>>> Hi Everyone..
>>> 
>>> I am loosing my mind with NSURL's initFileURLWithPath. (Trying to build a 
>>> 10.5 app.. btw)
>>> 
>>> If I create a NSURL object with a local file path, everything looks as it 
>>> should, when stepping through the code with the debugger.
>>> However, when I use "[myURL path]" in my code, I get a path to my binary 
>>> instead of the path that is placed into NSURL object.
>>> After doing some reading, this looks as if my local file path is being set 
>>> as the "Relative" path, and the binary application is set as
>>> the "BaseURL".
>>> 
>>> Can someone (preferably from Apple) explain why this is broken with file 
>>> paths?
>>> -- Yes.. it is broken, as there is no way to set the baseURL, nor is there 
>>> a way to set my local file path as the baseURL.
>>> --- I used absoluteURL, but that only returns the binary path.
>>> 
>>> I hope I don't have to remove these NSURL objects and replace them with 
>>> NSStrings..
>>> what a pain in the a..
>>> 
>>> bob.
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post 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/cocoadev%40mikeabdullah.net
>>> 
>>> This email sent to cocoa...@mikeabdullah.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:
> http://lists.apple.com/mailman/options/cocoa-dev/karthikreddy09%40gmail.com
> 
> This email sent to karthikredd...@gmail.com

___

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

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

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

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


Re: baseURL problem with +fileURLWithPath:

2010-05-18 Thread Robert Monaghan
Immediately after the NSURL object is created.
(so there is no danger of being released.)

bob.

On May 18, 2010, at 2:03 PM, Volker in Lists wrote:

> Robert,
> 
> when/where do you call [url path]? It may be released at that moment and thus 
> display garbage! What happens if you omit the call to autorelease when 
> creating url ?
> 
> Volker
> 
> Am 18.05.2010 um 13:52 schrieb Robert Monaghan:
> 
>> Hi Mike,
>> 
>> This is pretty trivial.. I have a string that is coming from an FCP XML 
>> file. The string looks like this:
>> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
>> 
>> I then pass the string to an NSURL object using: (Yes, I know I can do a 
>> "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
>> NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
>> objectAtIndex:0] stringValue]] autorelease];
>> 
>> Then, I try to get an NSString object by doing:
>> [url path]
>> 
>> This is where things go wildly wrong.. the NSString value ends up being a 
>> path to my binary.
>> 
>> 
> 

___

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

Please do not post 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: baseURL problem with +fileURLWithPath:

2010-05-18 Thread Volker in Lists
Robert,

when/where do you call [url path]? It may be released at that moment and thus 
display garbage! What happens if you omit the call to autorelease when creating 
url ?

Volker

Am 18.05.2010 um 13:52 schrieb Robert Monaghan:

> Hi Mike,
> 
> This is pretty trivial.. I have a string that is coming from an FCP XML file. 
> The string looks like this:
> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
> 
> I then pass the string to an NSURL object using: (Yes, I know I can do a 
> "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
> NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
> objectAtIndex:0] stringValue]] autorelease];
> 
> Then, I try to get an NSString object by doing:
> [url path]
> 
> This is where things go wildly wrong.. the NSString value ends up being a 
> path to my binary.
> 
> 

___

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

Please do not post 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: baseURL problem with +fileURLWithPath:

2010-05-18 Thread Robert Monaghan
Hi Mike,

This is pretty trivial.. I have a string that is coming from an FCP XML file. 
The string looks like this:
file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov

I then pass the string to an NSURL object using: (Yes, I know I can do a 
"fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray 
objectAtIndex:0] stringValue]] autorelease];

Then, I try to get an NSString object by doing:
[url path]

This is where things go wildly wrong.. the NSString value ends up being a path 
to my binary.


bob.


On May 18, 2010, at 12:55 PM, Mike Abdullah wrote:

> Show us some code.
> 
> On 18 May 2010, at 09:49, Robert Monaghan wrote:
> 
>> Hi Everyone..
>> 
>> I am loosing my mind with NSURL's initFileURLWithPath. (Trying to build a 
>> 10.5 app.. btw)
>> 
>> If I create a NSURL object with a local file path, everything looks as it 
>> should, when stepping through the code with the debugger.
>> However, when I use "[myURL path]" in my code, I get a path to my binary 
>> instead of the path that is placed into NSURL object.
>> After doing some reading, this looks as if my local file path is being set 
>> as the "Relative" path, and the binary application is set as
>> the "BaseURL".
>> 
>> Can someone (preferably from Apple) explain why this is broken with file 
>> paths?
>> -- Yes.. it is broken, as there is no way to set the baseURL, nor is there a 
>> way to set my local file path as the baseURL.
>> --- I used absoluteURL, but that only returns the binary path.
>> 
>> I hope I don't have to remove these NSURL objects and replace them with 
>> NSStrings..
>> what a pain in the a..
>> 
>> bob.
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/cocoadev%40mikeabdullah.net
>> 
>> This email sent to cocoa...@mikeabdullah.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Regarding MVC design pattern

2010-05-18 Thread Sai
Hi all,

Thanks for your reply. I didn't retain that, I will try that as soon as I
get home.
Anyway, why I should retain that? Will it be released by "somebody"? Can
anyone tell me the whole process and what's going on please? I want to know
what happened. Thanks a lot.

On Tue, May 18, 2010 at 7:07 PM, Jack Nutting  wrote:

> On Tue, May 18, 2010 at 12:40 PM, Sai  wrote:
> > However, I declare a NSDictionary instance variable in my model object.
> This
> > NSDictionary instance
> > store some data I need. And I will create this NSDictionary instance by
> > invoking:
> > [NSDictionary dictionaryWithObjects:names forKeys:keys]
>
> Are you retaining that?
>
> - (id)init {
>  if (self = [super init]) {
>// assuming you have an ivar called "dict", this will lead to the
> problem you define:
>dict = [NSDictionary dictionaryWithObjects:names forKeys:keys];
>// but this should work:
>dict = [[NSDictionary dictionaryWithObjects:names forKeys:keys] retain];
>   }
> }
>
> --
> // jack
> // http://nuthole.com
> // http://learncocoa.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Regarding MVC design pattern

2010-05-18 Thread Jack Nutting
On Tue, May 18, 2010 at 12:40 PM, Sai  wrote:
> However, I declare a NSDictionary instance variable in my model object. This
> NSDictionary instance
> store some data I need. And I will create this NSDictionary instance by
> invoking:
> [NSDictionary dictionaryWithObjects:names forKeys:keys]

Are you retaining that?

- (id)init {
  if (self = [super init]) {
// assuming you have an ivar called "dict", this will lead to the
problem you define:
dict = [NSDictionary dictionaryWithObjects:names forKeys:keys];
// but this should work:
dict = [[NSDictionary dictionaryWithObjects:names forKeys:keys] retain];
  }
}

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

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


Re: Regarding MVC design pattern

2010-05-18 Thread Alexander Spohr

Am 18.05.2010 um 12:40 schrieb Sai:

> Unfortunately, when I try to get value from that NSDictionary, I will get 
> exc_bad_access signal, and I follow gdb, the NSDictionary instance seems to
> be corrupted.

> So where does it go wrong? Hopefully I state things clearly this time. Thank
> you all.

Do you retain it?
Show the code.

atze

___

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

Please do not post 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: Specify "Sent Action on" Behavior of NSTextField

2010-05-18 Thread René v Amerongen
In IB, move with the mouse over the popup item.

Op 18 mei 2010, om 10:21 heeft Dong Feng het volgende geschreven:

> There is a option on IB to specify if an NSTextField "Sent Action on
> Enter Only" or "Sent Action on Editing." How to set the option
> programmatically?
> 
> Thanks,
> Dong
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/appledev%40xs4all.nl
> 
> This email sent to apple...@xs4all.nl

___

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

Please do not post 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: Regarding MVC design pattern

2010-05-18 Thread Joanna Carter
Hi Sal

> However, I declare a NSDictionary instance variable in my model object. This
> NSDictionary instance
> store some data I need. And I will create this NSDictionary instance by
> invoking:
> [NSDictionary dictionaryWithObjects:names forKeys:keys]
> Both names and keys are string NSArray. I will invoke this method inside my
> init method of my model
> object.

And this is where your problem could well be. If you create anything in the 
init method, and it references the Nib, then the connections won't be correctly 
made.

Try moving your dictionary creation code to the awakeFromNib method. This is 
called after the Nib is fully loaded.

Joanna

--
Joanna Carter
Carter Consulting

___

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

Please do not post 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: baseURL problem with +fileURLWithPath:

2010-05-18 Thread Mike Abdullah
Show us some code.

On 18 May 2010, at 09:49, Robert Monaghan wrote:

> Hi Everyone..
> 
> I am loosing my mind with NSURL's initFileURLWithPath. (Trying to build a 
> 10.5 app.. btw)
> 
> If I create a NSURL object with a local file path, everything looks as it 
> should, when stepping through the code with the debugger.
> However, when I use "[myURL path]" in my code, I get a path to my binary 
> instead of the path that is placed into NSURL object.
> After doing some reading, this looks as if my local file path is being set as 
> the "Relative" path, and the binary application is set as
> the "BaseURL".
> 
> Can someone (preferably from Apple) explain why this is broken with file 
> paths?
> -- Yes.. it is broken, as there is no way to set the baseURL, nor is there a 
> way to set my local file path as the baseURL.
> --- I used absoluteURL, but that only returns the binary path.
> 
> I hope I don't have to remove these NSURL objects and replace them with 
> NSStrings..
> what a pain in the a..
> 
> bob.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

> I dunno about that.. I was just selecting French from the pop up list when I 
> clicked the "Make localizable" button under info of the xib file, and then I 
> put in the first position of the lang list under system preferences French 
> language... re build re run and nothing, I logout and login again the system 
> and all was in french (finder) but still when running I was seeing the 
> English version of the xib. I tried also for another lang sk_SK (for 
> Slovakia) and nothing also... 
> 
> 
> Its wird, Im not localizing  my app yet, but Im getting ready for the task 
> which will come very soonso thats why its urgent for me to at least make 
> a test app localized.

Do you fancy sending me your test app? I run OS X in French all the time and 
often localise from the default English to French.

Don't forget to clean out the Build folder before zipping and sending it :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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

Please do not post 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: Regarding MVC design pattern

2010-05-18 Thread Sai
Hi,

Sorry I haven't given full details. I just found where the exc_bad_access
signal comes from.
I have a controller object and a model object, both are created in the
interface builder. So I suppose
they are stored in the XIB document. That's why they are initialized
automatically as you guys mentioned.
My controller class has an IBOutlet variable which is an instance of that
Model object. I did connect this
IBOutlet to that Model object in the interface builder. So everything should
be fine as expected.
However, I declare a NSDictionary instance variable in my model object. This
NSDictionary instance
store some data I need. And I will create this NSDictionary instance by
invoking:
[NSDictionary dictionaryWithObjects:names forKeys:keys]
Both names and keys are string NSArray. I will invoke this method inside my
init method of my model
object. So everything should be initialized when the Nib file is
loaded(model object will be initialized and
hence the NSDictionary will be initialized as well). Unfortunately, when I
try to get value from that
NSDictionary, I will get exc_bad_access signal, and I follow gdb, the
NSDictionary instance seems to
be corrupted. Every other instance else(all are primitive types) in that
Model object are fine(contains
correct value).
So where does it go wrong? Hopefully I state things clearly this time. Thank
you all.

On Mon, May 17, 2010 at 1:29 PM, Henry McGilton <
appledevelo...@trilithon.com> wrote:

>
> On May 15, 2010, at 10:56 AM, Sai wrote:
>
> > Hi All,
> > I am new to cocoa development. Suppose I have an iPhone application
> follow
> > the MVC design pattern.
> > The Model is presented by an custom object. And I have declared an
> instance
> > of the Model Object as a IBOutlet
> > in my Controller class.
>
> One assumes from your description here that there is a custom object in
> your XIB document.
> And, as you said, your Controller class has an IBOutlet declaration for the
> Model.
>
> Is there an instance of your Controller class in the XIB document?
> Did you connect that Controller's Model IBOutlet to the Model object itself
> using Interface Builder?
>
> If it's not connected in the XIB document, you need to make the connection,
> and then the alloc and init
> you do as described below is no longer necessary.
>
>
> > I found that every time I start my application, this
> > instance of Model Object will be initialized.
> > My first question is who called this init method, what for?
>
> The alloc and init are called when the NIB is loaded.
>
> >
> > As I found that it will be initialized automatically, so I just send
> message
> > for that instance, and crashed at runtime
> > with a exc_bad_access signal error. So I have to call alloc and init for
> > that Model Object and assign the returned
> > instance to the IBOutlet variable, then everything runs well.
>
> > My second question is if I have to allocate and initialized that Model
> > Object for myself? Is it over-done for this
> > initialization because it is called automatically before.
>
> Yes, but if you had made the connection from Controller to Model in the XIB
> document,
> you would not need to alloc and init a new instance.
>
> > My third question is where I should call the release method for this
> > instance of Model Object?
>
> You release the Model object when you no longer need it.
>
>Best Wishes,
> . . . . . . . .Henry
>
>
___

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

Please do not post 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: My program causes MacBook Pro to use NVidia graphics

2010-05-18 Thread Keith Blount
Hi Gideon,

Thanks for the reply and the update. I don't think I'm going to spend time 
worrying about it for now either given that it's not something I am doing 
directly. I have exactly the same situation as you, where my app has linked 
against the same libraries for two or three years and has been used by 
thousands of people, and this recent Twitter comment was the first I've heard 
of anything like this happening, on a MacBook Pro too. In a way it's good just 
knowing that it's not something limited only to my application.

Thanks and all the best,
Keith



From: Gideon King 
To: Keith Blount 
Cc: cocoa-dev@lists.apple.com
Sent: Tue, May 18, 2010 11:01:41 AM
Subject: Re: My program causes MacBook Pro to use NVidia graphics


I'm the one who started the thread, and it's the same for me - my program 
doesn't explicitly link against those libraries, but something somewhere 
obviously does. The first I knew about it was when a customer queried it, 
asserting that it was shortening his battery life on his laptop. 

Seeing as this is the first query about it when the app has linked against 
these same libraries for the last 2 years at least, and been used by many 
thousands of people on their laptops, I thought it probably wasn't too big of 
an issue, but was curious as to the cause. 

>From my empirical point of view, I judged that it didn't appear to be a 
>significant enough issue to warrant me spending any more time digging into the 
>causes and impacts.

Gideon

On 18/05/2010, at 7:28 PM, Keith Blount wrote:
...
>
>Is this something I should be concerned about? As I'm not explicitly calling 
>anything that should do this, I'm assuming it's just a quirk of the system 
>caused by one of the frameworks I'm linking against, in which case I assume 
>there's not much I could do anyway.
>
>


  
___

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

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

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

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


baseURL problem with +fileURLWithPath:

2010-05-18 Thread Robert Monaghan
Hi Everyone..

I am loosing my mind with NSURL's initFileURLWithPath. (Trying to build a 10.5 
app.. btw)

If I create a NSURL object with a local file path, everything looks as it 
should, when stepping through the code with the debugger.
However, when I use "[myURL path]" in my code, I get a path to my binary 
instead of the path that is placed into NSURL object.
After doing some reading, this looks as if my local file path is being set as 
the "Relative" path, and the binary application is set as
the "BaseURL".

Can someone (preferably from Apple) explain why this is broken with file paths?
-- Yes.. it is broken, as there is no way to set the baseURL, nor is there a 
way to set my local file path as the baseURL.
--- I used absoluteURL, but that only returns the binary path.

I hope I don't have to remove these NSURL objects and replace them with 
NSStrings..
what a pain in the a..

bob.

___

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

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