Re: NSNull vs nil in NSManagedObject setValue: v forKey: k

2010-03-01 Thread Quincey Morris
On Feb 28, 2010, at 23:12, Eagle Offshore wrote:

> Documentation?  "NSNull" does not appear in the documentation.
> http://developer.apple.com/mac/library/documentation/cocoa/reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html
> 
> NSNull is conceptually the wrapper for nil,

No, this is a false statement. See:


http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNull_Class/Reference/Reference.html

"The NSNull class defines a singleton object used to represent null values in 
collection objects (which don’t allow nil values)."

Getting "the wrapper for nil" out of this is going a bit too far.

> like NSNumber is the wrapper for a number.

And this is a false statement (because of the word "like"). KVC has the 
built-in ability to transform numeric property values to and from NSNumber 
objects. There is no such behavior involving NSNull.

> It is conceptually inconsistent to treat them differently.

Therefore this is also a false statement. There is a certain superficial 
similarity between nil/NSNull and number/NSNumber, perhaps, but that's about 
all.

> NSMutableDictionary* dict = [NSMutableDictionary dictionary];
> 
> [dict setObject: 5 forKey: @"foo"]  // fails - must have object
> [dict setObject [NSNumber numberWithInt: 5] forKey: @"foo"]; // OK
> 
> [dict setObject: nil forKey: @"bar"] // fails - must have object
> [dict setObject: [NSNull null] forKey: @"bar"]; // OK
> 
> NSManagedObject* obj; // gets created somehow
> 
> [obj setValue: nil forKey: @"bar"]; // succeeds where NSDictionary fails
> [obj setValue: [NSNull null] forKey: @"bar"]; // fails where NSDictionary 
> succeeds

Of course it fails. '[dict setObject: ... forKey: @"bar"];' sets the object for 
a key in a dictionary. '[obj setValue: ... forKey: @"bar"];' sets the value of 
an object property. The two mechanisms are unrelated.

> so - this is conceptually buggy thinking and the thoughtful developer could 
> be forgiven for being VERY SURPRISED by this behavior that is NOT DOCUMENTED.


___

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

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

Help/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: NSNull vs nil in NSManagedObject setValue: v forKey: k

2010-03-01 Thread Eagle Offshore
Reconcile that with integers and I might buy it.

But in general, KVC requires object wrappers for things you can't put into 
containers.
NSNull should result in nil when used KVC calls just like NSNumber results in 
an integer.


On Feb 28, 2010, at 11:53 PM, Alexander Spohr wrote:

> 
> Am 01.03.2010 um 08:12 schrieb Eagle Offshore:
> 
>> NSManagedObject* obj; // gets created somehow
>> 
>> [obj setValue: nil forKey: @"bar"]; // succeeds where NSDictionary fails
>> [obj setValue: [NSNull null] forKey: @"bar"]; // fails where NSDictionary 
>> succeeds
>> 
>> so - this is conceptually buggy thinking and the thoughtful developer could 
>> be forgiven for being VERY SURPRISED by this behavior that is NOT DOCUMENTED.
> 
> Wat if you use subclasses of NSManagedObject as I always do?
> 
> [obj setBar:[NSNull null]] // has to fail, I need a string!
> 
> Your comparison to NSDictionary is wrong. NSManagedObject is a (good working) 
> placeholder for a class with properties and not just a container like 
> NSDictionary.
> 
> If you build a method that takes an NSString you would not want NSNull in it, 
> do you?
> 
>   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: action for raise and lower baseline of textview

2010-03-01 Thread Quincey Morris
On Feb 28, 2010, at 23:33, XiaoGang Li wrote:

>   When creating my document-based application, there is a default menu
> item, Format->Font->Baseline. select text on the text view, then click the
> Raise or Lower menu, I find something that I can not understand.
>Click Raise menu first, the space between the lines increase.
>But if click Lower menu first, the space between the lines still
> increase. why?

It makes sense to me. Let's pretend that the line spacing is the total of the 
font ascent plus the font descent. (That's not quite right, but let's pretend.) 
If you raise the baseline of some text, the line spacing is the total of the 
font ascent of the raised text, plus the distance between the raised text's 
baseline and normal text's baseline, plus the normal font descent. That's 
greater than the normal line spacing.

If you lower some text, the line spacing is the total of the normal font 
ascent, plus the distance between the normal baseline and the lowered text 
baseline, plus the lowered text's descent. Again, that's greater than the 
normal line spacing.

In other words, if you shove some text up, you have to make some extra room 
above to shove it into. If you drop text down, you have to make extra room 
below to drop it into.

That's all assuming you don't change the point size. If you make the 
raised/lowered text smaller, you might not need extra space.

>Another:
>First, click the Raise, the space between the lines increase. then
> click lower, the space decrease. but if still click Lower, the increase will
> increase, (not decrease anymore).

This is just a special case of the 
above.___

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

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

Help/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: NSNull vs nil in NSManagedObject setValue: v forKey: k

2010-03-01 Thread Quincey Morris
On Mar 1, 2010, at 00:12, Eagle Offshore wrote:

> But in general, KVC requires object wrappers for things you can't put into 
> containers.

In general (that is, in generic methods like valueForKey: and 
setValue:forKey:), KVC requires object pointers for values. It has nothing to 
do with containers -- the same is true for simple property values too.

So, KVC has to convert scalar values to/from objects, for scalar properties. 
But it doesn't have to convert nil for object pointer properties, because nil 
is already a valid object pointer.

The only complication comes when you specify nil for the value of a scalar 
property (still nothing to do with collections). In that case, KVC can't do the 
conversion, and it's handled by the setNilValueForKey: mechanism.

> NSNull should result in nil when used KVC calls just like NSNumber results in 
> an integer.

It doesn't, though. KVC doesn't do anything special with NSNull. NSNull is 
there for collections, not for KVC.


___

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

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

Help/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: Carbon is C++?

2010-03-01 Thread Jean-Daniel Dupas

Le 1 mars 2010 à 05:55, Erik Buck a écrit :

> 
> On Feb 28, 2010, at 10:49 PM, David Rowland wrote:
> 
>> 
>> On Feb 28, 2010, at 7:24 PM, Erik Buck wrote:
>> 
>>> I disagree.  I have written very low latency device drivers in Objective-C. 
>>>  Why do you think Objective-C has too much "latency" for audio?  When 
>>> properly used, Objective-C programs are no more likely to be preempted than 
>>> any other kind of program.  Message dispatch generally has constant time 
>>> and is only 2.5 times the cost of a C function call.
>> 
>> That just cannot be true. But if you need speed you can write a direct C 
>> style subroutine and call, and it will be swift. The dynamic binding of ObC 
>> messages often isn't needed.
> 
> http://www.mikeash.com/pyblog/performance-comparisons-of-common-operations-leopard-edition.html
> http://www.friday.com/bbum/2009/12/18/objc_msgsend-part-1-the-road-map/
> http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/
> http://www.mulle-kybernetik.com/artikel/Optimization/
> 
> See gcc option -fobjc-direct-dispatch
> 

This option is a noop on Intel arch. 
And it does not prevent the main issue when dealing with objc_msgSend. The 
dispatch time is not constant. 
The runtime may have to use slow dispatch path when the method is not cached 
(and even have to use malloc to increase cache size).


> Interesting research: http://www.jot.fm/issues/issue_2009_01/article4/
> 
>> 
>> 
>>> There aren't many function calls or messages sent in audio processing 
>>> anyway.  Signal processing routines tend to be long loops.  Objective-C 
>>> _IS_ C which means it is likely usable in any situation where C is usable.
>>> 
>>> 
>> 
> 

-- 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: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Joanna Carter
Hi Ken

> Why do you think that?  What aspect of your design leads you to that 
> conclusion?

I have a one-to-many relationship between two classes but, with a slight 
twist...

MasterObject 1..n DerivedDetailObject

DerivedDetailObject inherits from BaseDetailObject

BaseDetailObject n..1 MasterObject

So, it is a two-way relationship, split by inheritance on the detail side :-)

> Normally, an outlet would be something that the class inherently uses (or 
> would use if connected).  Since NSArrayController has no already existing 
> need for the outlet you're adding, and doesn't know to use it if it's present 
> and connected, it doesn't make sense to create a subclass solely for the 
> purpose of adding it.

The need for subclassing an array controller is to override the addObject: 
method to set the "master" property on each object that gets added to the 
"detail" list.

> You don't bind an outlet, you merely connect it.  And you connect it to an 
> object, not a property of an object.  Your choice of terminology makes me 
> wonder if what you really want to do is create a new binding, which is a 
> different kind of thing from an outlet.

Yup, I do realise there is a difference between outlets and bindings. It's just 
that I haven't yet discovered how to declare the two sides of a binding, that 
can be completed in IB.

Unless, of course, there is another way to circumvent the problem of resolving 
the "split" relationship.

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: action for raise and lower baseline of textview

2010-03-01 Thread XiaoGang Li
Thanks very much, I understand your words.

On Mon, Mar 1, 2010 at 4:24 PM, Quincey Morris
wrote:

> On Feb 28, 2010, at 23:33, XiaoGang Li wrote:
>
> >   When creating my document-based application, there is a default
> menu
> > item, Format->Font->Baseline. select text on the text view, then click
> the
> > Raise or Lower menu, I find something that I can not understand.
> >Click Raise menu first, the space between the lines increase.
> >But if click Lower menu first, the space between the lines still
> > increase. why?
>
> It makes sense to me. Let's pretend that the line spacing is the total of
> the font ascent plus the font descent. (That's not quite right, but let's
> pretend.) If you raise the baseline of some text, the line spacing is the
> total of the font ascent of the raised text, plus the distance between the
> raised text's baseline and normal text's baseline, plus the normal font
> descent. That's greater than the normal line spacing.
>
> If you lower some text, the line spacing is the total of the normal font
> ascent, plus the distance between the normal baseline and the lowered text
> baseline, plus the lowered text's descent. Again, that's greater than the
> normal line spacing.
>
> In other words, if you shove some text up, you have to make some extra room
> above to shove it into. If you drop text down, you have to make extra room
> below to drop it into.
>
> That's all assuming you don't change the point size. If you make the
> raised/lowered text smaller, you might not need extra space.
>
> >Another:
> >First, click the Raise, the space between the lines increase. then
> > click lower, the space decrease. but if still click Lower, the increase
> will
> > increase, (not decrease anymore).
>
> This is just a special case of the
> above.___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/andrew.macdev%40gmail.com
>
> This email sent to andrew.mac...@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


registering Defaults with NSUserDefaults not working

2010-03-01 Thread Gustavo Pizano
Hello.

Before all, I checked on google and the Docs for info, and I don't see what I 
might be doing wrong.

This is what Im doing, following the AppPref example but of course for a 
desktop app.

In my  - (void)applicationDidFinishLaunching:(NSNotification *)aNotification{

I have the following:

id testValue =[[NSUserDefaults standardUserDefaults] 
objectForKey:kNotPayedGradientKey];

if(testValue == nil){ //No values yet registered
//..Creating NSGradients and Put converting them as NSData
_notPayedGradient = [[NSGradient alloc] initWithStartingColor:[NSColor 
colorWithCalibratedRed:_notPayedRedColor green:_notPayedGreenColor 
blue:_notPayedBlueColor 
  alpha:1.0f]   
endingColor:[NSColor colorWithCalibratedRed:_notPayedRedColor + 0.1 
green:_notPayedGreenColor + 0.1 

  blue:_notPayedBlueColor + 0.1 alpha:1.0f]];

NSData * notPayedData = [NSKeyedArchiver 
archivedDataWithRootObject:_notPayedGradient];

then after creating all the gradients I do:

NSDictionary * appDefaults = [NSDictionarydictionaryWithObjectsAndKeys:
notPayedData,kNotPayedGradientKey
,partPayedData,kPartPayedGradientKey,
payedData,kPayedGradientKey,nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
if([[NSUserDefaults standardUserDefaults] synchronize])NSLog(@"Could Save");

So, I ran my app, and as expected I enter the if statement,  and I see in the 
console, the  "Could Save" message.

I ran again, expecting not to enter the if statement, but for my surprise it 
came in again. the testValue is always nil. I change then:

NSString * testValue = [NSUserDefaults standardUserDefaults] 
stringForKey:kNotPayedGradientKey]; 

to see if the given key existed, but still nothing. I went to checn the .plist 
in the /users//library/preferences, and there my old 
com.mycompany..plist, but there is nothing inside,  I change then the 
target identifier to something else, and when running and going into the 
preferences folder there is no such a ,plist... 

What can I do?, what am I doing wrong?

Thx in advance any help will be appreciate it.

Gustavo.




___

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

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

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

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


Re: Core Data - synchronize ManagedObjectContexts - save date

2010-03-01 Thread Volker in Lists
Hi,

some code may help! When using its own context for a NSOperation it works very 
well for me. I never call save when in the NSOperation.

Volker

Am 01.03.2010 um 00:20 schrieb Rainer Standke:

> Hello,
> 
> I have an document-based CoreData application that uses an NSOperation to 
> manipulate ManagedObjects. I can successfully synchronize the main thread's 
> context, using mergeChangesFromContextDidSaveNotification:.
> 
> However, when I subsequently try to save the document I get a warning that 
> the doc has been saved by another application. This happens in spite of the 
> fact that I update the doc's fFileModificationDate right after 
> synchronisation.
> 

___

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

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

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

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


Re: Is there any Cocoa API (or other way) to determine if an application is running in a VNC or ARD session?

2010-03-01 Thread Uli Kusterer
On 27.02.2010, at 00:53, Joe Jones wrote:
> Why? So we can limit certain functionality over a remote connection. We do 
> this for Terminal Services connections on Windows and I was asked about doing 
> it for Mac.


 If you want this so you can limit e.g. whether users can see the contents of 
certain windows, you may also want to look into the CGWindow APIs/certain 
methods on NSWindow. I think their name is something like "window sharing". 
Essentially, they let you tell the OS that certain windows should not be 
screenshottable. That may work for VNC connections as well, I haven't tried it. 
But it's worth investigating.

Cheers,
-- 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: Carbon is C++?

2010-03-01 Thread Greg Parker
On Feb 28, 2010, at 7:24 PM, Erik Buck wrote:
> I disagree.  I have written very low latency device drivers in Objective-C.  
> Why do you think Objective-C has too much "latency" for audio?  When properly 
> used, Objective-C programs are no more likely to be preempted than any other 
> kind of program.  Message dispatch generally has constant time and is only 
> 2.5 times the cost of a C function call.  There aren't many function calls or 
> messages sent in audio processing anyway.  Signal processing routines tend to 
> be long loops.  Objective-C _IS_ C which means it is likely usable in any 
> situation where C is usable.

Message dispatch is generally fast. For many real-time-ish purposes that's good 
enough. But occasionally message dispatch (1) takes much longer, and (2) 
acquires locks. For some real-time-ish purposes, this sort of surprise is fatal 
when it occurs. Since there's no way for the program to control when dispatch 
is fast and when it is slow, clients with sufficiently tight "no surprises" 
requirements should avoid it altogether. If your requirements are demanding 
enough that you can't call malloc(), then you probably can't call 
objc_msgSend() either.

It's the locks that kill. With care, a real-time-ish thread can pretty much 
solve problems of page faults and scheduling and the like. But the moment you 
take a lock, you're at the mercy of some other thread that may not be so 
careful. 

Audio clients tend to be the most paranoid about this on Mac OS X. They're the 
closest to truly-real-time requirements that I see, with good reason: if your 
audio playback skips, ever, you probably just lost a customer.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

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

Help/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: UITextView as its own delegate - infinite loop on keyboard select

2010-03-01 Thread Roland King

On 01-Mar-2010, at 9:29 AM, Kyle Sluder wrote:

> On Sat, Feb 27, 2010 at 6:37 PM, Roland King  wrote:
>> Thanks that's what I see too. That thread doesn't explain why of course. I
>> have a trivial test case so I'll file this as a bug and see what comes back
>> because I think the behaviour is wrong. For now I'm using a different object
>> as delegate, which isn't so neat but works fine.
> 
> The thread does explain exactly what's going on in the UITextField
> case: it sends itself messages which are also sent to the delegate.
> 
> In your case, -[UITextView keyboardInputChangedSelection:] calls [self
> textViewDidChangeSelection:], which in turn asks if [self.delegate
> respondsToSelector:@selector(textViewDidChangeSelection:)], which
> obviously returns YES, so it calls [self.delegate
> textViewDidChangeSelection:]. Because self == delegate, you infinitely
> recurse.
> 

There's two reasons that theory doesn't appear to be right in this case. 

Firstly if that's what happened, the program would recurse, the stack would be 
full of textViewDidChangeSelection: calls each calling the next, but that is 
not what happens, the program hangs, the code infinitely loops, but it does not 
recurse, the stack stays about 20 stack frames deep. 

Secondly, respondsToSelector:@selector(textViewDidChangeSelection:) doesn't 
return YES, it returns NO (which is what I'd expect because I haven't 
implemented it or anything else come to that matter). UITextView does not 
implement or respond to textViewDidChangeSelection:. (UITextView does implement 
the other method in that trace, keyboardInputChangedSelection: but that's not a 
delegate method, it's not even a documented method so it must be private.)

I think that thread is also confused about the delegate pattern as used in 
cocoa and mixes it up with the more general decorator pattern. The notion 
stated early in that thread is that delegation means if you yourself do not 
respond to a given selector, you ask your delegate if it responds to it. That 
may be close to what decoration means, but it's not cocoa delegation where 
there are a set of selectors your delegate may/must respond to, but they are in 
general a different set of selectors from those your class implements and they 
are conditionally called on the delegate object only, not the class itself, 
during the processing of a usually entirely differently named method. 

I agree that if a class implemented one of its own delegate methods and if that 
implementation called the delegate's implementation of that method without 
checking for delgate==self and if you then went to set delegate=self you'd 
recurse (I think if a class allowed that to happen by not checking that it 
would be a bug by the way). That's not what's happening here however, 
UITextView doesn't implement the delegate method, it's not being called and the 
code isn't recursing, it's looping for a different reason. 

I filed this one as a bug, I'll see what comes back and if I get a 'works 
correctly' on it I'll go burn up a support incident, I have two and they're 
expiring all too soon anyway. If anything interesting comes out of it I'll 
follow up. 


___

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

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

Help/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: Carbon is C++?

2010-03-01 Thread Uli Kusterer
On 26.02.2010, at 15:12, Sean McBride wrote:
> the STL Debug mode is broken on 10.6, etc., etc.  C++ support is good, but 
> it's not great.


 I guess this is off-topic for this list, but could you maybe give a short link 
or so regarding what "the STL debug mode" would be, and how it is broken? I'm 
using lots of C++, and this would be helpful.

Cheers,
-- 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: Carbon is C++?

2010-03-01 Thread Ariel Feinerman
Hi,
everyone say: "ObjC is slower then C++", but I/O Kit in the NextStep was
written in ObjC, I really don`t think Next`s engineers didn`t know that. Now
many crazy people write games in C# (managed language), but says that ObjC
is not appropriate because it dynamically. Your experience is greater then
mine, what do you think?

2010/3/1 Greg Parker 

> On Feb 28, 2010, at 7:24 PM, Erik Buck wrote:
> > I disagree.  I have written very low latency device drivers in
> Objective-C.  Why do you think Objective-C has too much "latency" for audio?
>  When properly used, Objective-C programs are no more likely to be preempted
> than any other kind of program.  Message dispatch generally has constant
> time and is only 2.5 times the cost of a C function call.  There aren't many
> function calls or messages sent in audio processing anyway.  Signal
> processing routines tend to be long loops.  Objective-C _IS_ C which means
> it is likely usable in any situation where C is usable.
>
> Message dispatch is generally fast. For many real-time-ish purposes that's
> good enough. But occasionally message dispatch (1) takes much longer, and
> (2) acquires locks. For some real-time-ish purposes, this sort of surprise
> is fatal when it occurs. Since there's no way for the program to control
> when dispatch is fast and when it is slow, clients with sufficiently tight
> "no surprises" requirements should avoid it altogether. If your requirements
> are demanding enough that you can't call malloc(), then you probably can't
> call objc_msgSend() either.
>
> It's the locks that kill. With care, a real-time-ish thread can pretty much
> solve problems of page faults and scheduling and the like. But the moment
> you take a lock, you're at the mercy of some other thread that may not be so
> careful.
>
> Audio clients tend to be the most paranoid about this on Mac OS X. They're
> the closest to truly-real-time requirements that I see, with good reason: if
> your audio playback skips, ever, you probably just lost a customer.
>
>
> --
> Greg Parker gpar...@apple.com Runtime Wrangler
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/arielfapple%40gmail.com
>
> This email sent to arielfap...@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: UITextView as its own delegate - infinite loop on keyboard select

2010-03-01 Thread Uli Kusterer
On 01.03.2010, at 12:05, Roland King wrote:
> Firstly if that's what happened, the program would recurse, the stack would 
> be full of textViewDidChangeSelection: calls each calling the next, but that 
> is not what happens, the program hangs, the code infinitely loops, but it 
> does not recurse, the stack stays about 20 stack frames deep. 


 I haven't read that thread, so you may well be true, but just going by your 
description, tail recursion optimizations, as well as IMP cacheing, could cause 
the behaviour you're observing.

Cheers,
-- 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: UITextView as its own delegate - infinite loop on keyboard select

2010-03-01 Thread Roland King

On 01-Mar-2010, at 7:34 PM, Uli Kusterer wrote:

> On 01.03.2010, at 12:05, Roland King wrote:
>> Firstly if that's what happened, the program would recurse, the stack would 
>> be full of textViewDidChangeSelection: calls each calling the next, but that 
>> is not what happens, the program hangs, the code infinitely loops, but it 
>> does not recurse, the stack stays about 20 stack frames deep. 
> 
> 
> I haven't read that thread, so you may well be true, but just going by your 
> description, tail recursion optimizations, as well as IMP cacheing, could 
> cause the behaviour you're observing.
> 

That is true, if the method actually existed at all and was called and 
recursed, those optimizations could look like that, thanks for pointing it out. 

In this case there's the extra point that the method doesn't actually exist and 
it's not being called at all (it's just being checked for in 
respondsToSelector:)___

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

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

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

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


Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Joanna Carter
I have discovered that adding a private ivar of type id to a class makes it 
visible as an IBOutlet in Interface Builder.

@interface MyController : NSObject
{
 @private
   id anIvar;

 ...
}

@end

Is this a known bug, or expected behaviour?

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: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Roland King
I can't find this in the Apple documentation (it says that you need IBOutlet) 
however I believe that the nutshell cocoa guide stated that to be the case. 

Doesnt have to be private actually, just id seems to be enough. 

It has that 'legacy' feel about it. 

On 01-Mar-2010, at 8:40 PM, Joanna Carter wrote:

> I have discovered that adding a private ivar of type id to a class makes it 
> visible as an IBOutlet in Interface Builder.
> 
> @interface MyController : NSObject
> {
> @private
>   id anIvar;
> 
> ...
> }
> 
> @end
> 
> Is this a known bug, or expected behaviour?
> 
> 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/rols%40rols.org
> 
> This email sent to r...@rols.org

___

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

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

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

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


Re: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Joanna Carter
Le 1 mars 2010 à 12:59, Roland King a écrit :

> I can't find this in the Apple documentation (it says that you need IBOutlet) 
> however I believe that the nutshell cocoa guide stated that to be the case. 
> 
> Doesnt have to be private actually, just id seems to be enough. 
> 
> It has that 'legacy' feel about it. 

Hmmm, it also "feels" like a modern day bug :-)

Is there a mechanism for bug reporting?

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: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Roland King
http://bugreport.apple.com

you need at least some kind of apple developer ID, free one is fine. 

On 01-Mar-2010, at 9:10 PM, Joanna Carter wrote:

> Le 1 mars 2010 à 12:59, Roland King a écrit :
> 
>> I can't find this in the Apple documentation (it says that you need 
>> IBOutlet) however I believe that the nutshell cocoa guide stated that to be 
>> the case. 
>> 
>> Doesnt have to be private actually, just id seems to be enough. 
>> 
>> It has that 'legacy' feel about it. 
> 
> Hmmm, it also "feels" like a modern day bug :-)
> 
> Is there a mechanism for bug reporting?
> 
> 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: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Joanna Carter
Le 1 mars 2010 à 13:13, Roland King a écrit :

> http://bugreport.apple.com
> 
> you need at least some kind of apple developer ID, free one is fine. 

Thanks. Reported #7701200.

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: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Joanna Carter
Hi folks

Does it help if I rephrase my question?

How can I derive from an existing class and add a means of binding a property 
on the derived class to a property of another object?

It would seem, from Ken's response (and from common sense thinking :-) ) that 
an outlet is not suitable as that can only connect the outlet to another 
object, not a property of an object.

So, I implemented some of the NSKeyValueBindingCreation protocol methods and am 
now able to setup a binding in code.

Is there an easy way to get to set the binding in IB? Or do I have to go 
through the complete IBPlugin route?

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: registering Defaults with NSUserDefaults not working

2010-03-01 Thread Keary Suska
On Mar 1, 2010, at 3:01 AM, Gustavo Pizano wrote:

> [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
> if([[NSUserDefaults standardUserDefaults] synchronize])NSLog(@"Could Save");

-registerDefaults: does not actually change default values, it simply sets what 
the default values should be in certain cases. You can read 
NSUserDefaultsController about ways to use default values. If you delete your 
plist preference file, then re-run, you might see different results. You might 
be happier in the long wrong if you follow the docs and have all of your 
application defaults in app delegate's +initialize, or as a pre-defined plist 
in your project. You also don't need to call -synchronize if your app will 
terminate normally (saving defaults is one of the exit functions).

HTH,

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

___

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

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

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

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


Re: registering Defaults with NSUserDefaults not working

2010-03-01 Thread Gustavo Pizano

On Mar 1, 2010, at 4:07 PM, Keary Suska wrote:

> On Mar 1, 2010, at 3:01 AM, Gustavo Pizano wrote:
> 
>> [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
>> if([[NSUserDefaults standardUserDefaults] synchronize])NSLog(@"Could Save");
> 
> -registerDefaults: does not actually change default values, it simply sets 
> what the default values should be in certain cases. You can read 
> NSUserDefaultsController about ways to use default values. If you delete your 
> plist preference file, then re-run, you might see different results. You 
> might be happier in the long wrong if you follow the docs and have all of 
> your application defaults in app delegate's +initialize, or as a pre-defined 
> plist in your project. You also don't need to call -synchronize if your app 
> will terminate normally (saving defaults is one of the exit functions).
> 
Well I did as the Apple example I mentioned, they where doing that in the 
applicationDidFinishLaunch. Nevertheless,  so .. I have my .plist in the 
resources with all the values of the colors for the gradients, so from there is 
where Im reading to create the defaults gradients and I want to save them into 
the userDefaults,  then when the User click the preferences menu item he/she 
can choose different colors, then I will generate internally the new gradients  
then use the [[NSUserDefaults standarUSerDefaults] 
setObjectForKey:kGradientKey]. If the user click the button restore defaults I 
will generate the defaults values form the .plist I have in the resources 
folder, and again set the gradient data.

I deleted the com.mycompany.myapp, reloaded the application and no files are 
generated again, shall i run it on release mode?.. :S. 

So I will put this bunch of code on the +initialize, and Check the 
NSUserDefaultsController, so see what other ideas it will give me as you 
suggested.

Thanks for the help

Gustavo


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

___

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

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

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

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


Writing string to pasteboard on 10.5 causes crash

2010-03-01 Thread Martin Hewitson
Dear list,

I have developed an app on SL but at all times compiled the app for 10.5. Today 
I got my hands on a leopard test machine to try out the app, and I get crashes 
due to various things. Some of these I've fixed, but I'm stuck at this one:

Part of the app has an NSTableView filled with strings. I am able to drag these 
strings from this 'library of strings' to another NSTextView. This all works 
find on SL, but on Leopard it sends the app either in to spinning beachball 
mode or it crashes. In the spinning beachball case I have to 'force quit' the 
app, and then I get a very long report which I can't extract any useful 
information from. The 'crash' actually happens before I reach a dragging 
destination, so it must be something at the source end. When the app crashes 
(rather than beachballs) I get the following (extract) crash report:

Thread 0 Crashed:
0   com.apple.CoreFoundation0x7fff8068e24f 
CFDictionaryRemoveValue + 63
1   com.apple.AppKit0x7fff80f3cec8 -[NSPasteboard 
setData:forType:] + 211
2   com.apple.AppKit0x7fff80f3cdcf -[NSPasteboard 
setString:forType:] + 122
3   com.mhsoft.TeXnicle 0x000100015d7c -[LibraryController 
tableView:writeRowsWithIndexes:toPasteboard:] + 651
4   com.apple.AppKit0x7fff80ddda72 -[NSTableView 
_performDragFromMouseDown:] + 651
5   com.apple.AppKit0x7fff80ddbbf8 -[NSTableView 
mouseDown:] + 653
6   com.apple.AppKit0x7fff80d93783 -[NSWindow 
sendEvent:] + 5068
7   com.apple.AppKit0x7fff80d60d46 -[NSApplication 
sendEvent:] + 5089
8   com.apple.AppKit0x7fff80cbb562 -[NSApplication run] 
+ 497
9   com.apple.AppKit0x7fff80c882f0 NSApplicationMain + 
373
10  com.mhsoft.TeXnicle 0x00015d40 main + 33
11  com.mhsoft.TeXnicle 0x000117c0 start + 52


Here's the bit of code that writes the string to the pasteboard:

- (BOOL)tableView:(NSTableView *)aTableView 
writeRowsWithIndexes:(NSIndexSet *)rowIndexes 
 toPasteboard:(NSPasteboard*)pboard
{   
if (aTableView == itemsTable) {

NSArray *items = [[contentsController arrangedObjects] 
objectsAtIndexes:rowIndexes];
NSMutableArray *strings = [NSMutableArray array];
for (NSDictionary *item in items) {
[strings addObject:[item valueForKey:@"Code"]];
}
//  id str = [[strings componentsJoinedByString:@"\n"] retain];
id str = [strings componentsJoinedByString:@"\n"];
NSLog(@"Writing to pboard: %@", str);
return [pboard setString:str forType:NSStringPboardType];
}

return NO;
}

At one point I became unsure about the autoreleased string I create by 
'componentsJoinedByString:' and if the pasteboard retains that or now, but I 
tested retaining and not, and it doesn't change anything. Can anyone see any 
obvious error? 

More info: this can really screw up the system pasteboard because sometimes 
after this crash I can no longer drag-n-drop text in any app and need to reboot 
to get things working again!

I'm hoping to avoid setting up a build environment on the Leopard machine, but 
maybe that's a little optimistic.

Any advice gratefully received.

I'd gladly send the app to anyone interested in running it. 

The SL working version can be found at: 
http://web.me.com/martinhewitson/BOBsoft/TeXnicle.html

Thanks in advance,

Martin


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

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

Help/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: Writing string to pasteboard on 10.5 causes crash

2010-03-01 Thread jonat...@mugginsoft.com

On 1 Mar 2010, at 16:03, Martin Hewitson wrote:

> Dear list,
> 
> I have developed an app on SL but at all times compiled the app for 10.5. 
> Today I got my hands on a leopard test machine to try out the app, and I get 
> crashes due to various things. Some of these I've fixed, but I'm stuck at 
> this one:
> 
> Part of the app has an NSTableView filled with strings. I am able to drag 
> these strings from this 'library of strings' to another NSTextView. This all 
> works find on SL, but on Leopard it sends the app either in to spinning 
> beachball mode or it crashes. In the spinning beachball case I have to 'force 
> quit' the app, and then I get a very long report which I can't extract any 
> useful information from. The 'crash' actually happens before I reach a 
> dragging destination, so it must be something at the source end. When the app 
> crashes (rather than beachballs) I get the following (extract) crash report:
> 
> Thread 0 Crashed:
> 0   com.apple.CoreFoundation  0x7fff8068e24f 
> CFDictionaryRemoveValue + 63
> 1   com.apple.AppKit  0x7fff80f3cec8 -[NSPasteboard 
> setData:forType:] + 211
> 2   com.apple.AppKit  0x7fff80f3cdcf -[NSPasteboard 
> setString:forType:] + 122
> 3   com.mhsoft.TeXnicle   0x000100015d7c -[LibraryController 
> tableView:writeRowsWithIndexes:toPasteboard:] + 651
> 4   com.apple.AppKit  0x7fff80ddda72 -[NSTableView 
> _performDragFromMouseDown:] + 651
> 5   com.apple.AppKit  0x7fff80ddbbf8 -[NSTableView 
> mouseDown:] + 653
> 6   com.apple.AppKit  0x7fff80d93783 -[NSWindow 
> sendEvent:] + 5068
> 7   com.apple.AppKit  0x7fff80d60d46 -[NSApplication 
> sendEvent:] + 5089
> 8   com.apple.AppKit  0x7fff80cbb562 -[NSApplication run] 
> + 497
> 9   com.apple.AppKit  0x7fff80c882f0 NSApplicationMain + 
> 373
> 10  com.mhsoft.TeXnicle   0x00015d40 main + 33
> 11  com.mhsoft.TeXnicle   0x000117c0 start + 52
> 
> 
> Here's the bit of code that writes the string to the pasteboard:
> 
> - (BOOL)tableView:(NSTableView *)aTableView 
> writeRowsWithIndexes:(NSIndexSet *)rowIndexes 
>toPasteboard:(NSPasteboard*)pboard
> { 
>   if (aTableView == itemsTable) {
>   
>   NSArray *items = [[contentsController arrangedObjects] 
> objectsAtIndexes:rowIndexes];
>   NSMutableArray *strings = [NSMutableArray array];
>   for (NSDictionary *item in items) {
>   [strings addObject:[item valueForKey:@"Code"]];
>   }
> //id str = [[strings componentsJoinedByString:@"\n"] retain];
>   id str = [strings componentsJoinedByString:@"\n"];
>   NSLog(@"Writing to pboard: %@", str);
>   return [pboard setString:str forType:NSStringPboardType];
>   }
>   
>   return NO;
> }
> 
Try preparing the pasteboard first with either of the following:

- (NSInteger)clearContents
- (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner

Regards

Jonathan Mitchell

Developer
http://www.mugginsoft.com

> At one point I became unsure about the autoreleased string I create by 
> 'componentsJoinedByString:' and if the pasteboard retains that or now, but I 
> tested retaining and not, and it doesn't change anything. Can anyone see any 
> obvious error? 
> 
> More info: this can really screw up the system pasteboard because sometimes 
> after this crash I can no longer drag-n-drop text in any app and need to 
> reboot to get things working again!
> 
> I'm hoping to avoid setting up a build environment on the Leopard machine, 
> but maybe that's a little optimistic.
> 
> Any advice gratefully received.
> 
> I'd gladly send the app to anyone interested in running it. 
> 
> The SL working version can be found at: 
> http://web.me.com/martinhewitson/BOBsoft/TeXnicle.html
> 
> Thanks in advance,
> 
> Martin
> 
> 
> Martin Hewitson
> Albert-Einstein-Institut
> Max-Planck-Institut fuer 
>Gravitationsphysik und Universitaet Hannover
> Callinstr. 38, 30167 Hannover, Germany
> Tel: +49-511-762-17121, Fax: +49-511-762-5861
> E-Mail: martin.hewit...@aei.mpg.de
> WWW: http://www.aei.mpg.de/~hewitson
> 
> 
> 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jonathan%40mugginsoft.com
> 
> This email sent to jonat...@mugginsoft.com

___

Cocoa-dev mailing list (Coco

Re: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Henry McGilton

On Mar 1, 2010, at 4:40 AM, Joanna Carter wrote:

> I have discovered that adding a private ivar of type id to a class makes it 
> visible as an IBOutlet in Interface Builder.
> 
> @interface MyController : NSObject
> {
> @private
>   id anIvar;
> 
> ...
> }
> 
> @end
> 
> Is this a known bug, or expected behaviour?
> 
> Joanna

Not a bug --- a Feature . . .

That is a legacy of Interface Builder on NextStep, from the days before the 
IBOutlet marker was added.

If you care to try it out, you will find that a method declaration of this form:

- (void)doSomething: (did)sender;

is viewed by Interface Builder as an IBAction method to which you can connect 
from some control . . .
That's also a legacy feature.

Cheers,
. . . . . . . .Henry

www.nonatomic-retain.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: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Quincey Morris
On Mar 1, 2010, at 05:45, Joanna Carter wrote:

> Does it help if I rephrase my question?
> 
> How can I derive from an existing class and add a means of binding a property 
> on the derived class to a property of another object?
> 
> It would seem, from Ken's response (and from common sense thinking :-) ) that 
> an outlet is not suitable as that can only connect the outlet to another 
> object, not a property of an object.
> 
> So, I implemented some of the NSKeyValueBindingCreation protocol methods and 
> am now able to setup a binding in code.
> 
> Is there an easy way to get to set the binding in IB? Or do I have to go 
> through the complete IBPlugin route?

You need to clarify your thinking. What you want (it appears) is a KVO derived 
property in a certain class -- in this case, one whose value is dependent on a 
property in a different class.

The reason that an outlet isn't suitable is *not* that it can't connect to a 
property (though it can't), but that an outlet isn't a derived property. It's 
merely a pointer -- an instance variable.

Implementing a derived property is usually very simple using KVO, and does 
*not* require bindings. For example:

...
{
BaseObject* myBaseObject;
}
@property BaseObject* myBaseObject;
@property (readonly) DerivedProperty* myDerivedProperty;
...
@synthesize myBaseObject;
+ (NSSet*) keyPathsForValuesAffectingMyDerivedProperty {
return [NSSet setWithObject: @"myBaseObject.itsProperty"];
}
- (DerivedProperty*) myDerivedProperty {
return myBaseObject.itsProperty;
}

The "myBaseObject" property doesn't have to be made public if you don't want. 
IIRC, in your case, you don't even have to create the property:

@property (readonly) DerivedProperty* myDerivedProperty;
...
+ (NSSet*) keyPathsForValuesAffectingMyDerivedProperty {
return [NSSet setWithObject: @"content.itsProperty"];
}
- (DerivedProperty*) myDerivedProperty {
return [self.content itsProperty];
}

That's the easy way. In more complicated cases, for example, if the derived 
value may depend on one of several objects determined at run time, you can use 
the underlying KVO technology via 'addObserver:forKeyPath:...'.

There's no need to even consider creating custom binding behavior unless you 
*need* to hook up the binding in IB. That is, pretty much, unless you cannot 
determine the object on which the derived property depends at the time you 
write your source code. That is, pretty much, unless you're trying to provide a 
derived property in an object implemented in a library or framework where the 
dependency goes outside the library/framework. (If you can work out what to 
depend on in your source code, it's more straightforward to write code for that 
than to write a bindings implementation.) That is, pretty much, unless someone 
other than yourself is responsible for choosing the object on which the derived 
property depends. That is, pretty much, unless you're writing an IB plugin 
anyway to make the object with the derived property generally available as a 
design element in IB.

It's very unlikely you actually want a binding in your case.

The fly in this ointment is that (unfortunately IMO) NSObject's implementation 
of the 'bind:toObject:withKeyPath:...' method happens to set up a KVO 
dependency similar to the one described above:

...
{
DerivedProperty* myDerivedProperty;
}
@property (readwrite) DerivedProperty* myDerivedProperty; // ugh, now 
it needs to be settable
...
@synthesize myDerivedProperty;
...
[self bind: @"myDerivedProperty" toObject: myBaseObject withKeyPath: 
@"itsProperty" options: nil]; // saved, um, nearly 3 lines of code

As I've argued ad nauseam in the past, this isn't actually a binding (not a 
complete binding), yet people have gotten into the habit of using it as a 
convenience method for a derived property but *calling* it a binding. It sounds 
like you've unnecessarily re-invented this particular broken wheel. (Broken, 
because a binding is required to be bi-directional, and the NSObject 
implementation -- and, I'd bet, your code -- isn't bi-directional.)

I'd recommend that you avoid it, and use the 'keyPathsForValuesAffecting...' 
pattern described above, if you can, as the most directly expressive idiom for 
what you're apparently trying to achieve.


___

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

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

Help/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: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Joanna Carter
Hi Henry

> Not a bug --- a Feature . . .
> 
> That is a legacy of Interface Builder on NextStep, from the days before the 
> IBOutlet marker was added.

Heheh, I was afraid if that. Surely it's about time, with all the other 
breaking changes for Snow Leopard, that that got broken as well? :-)

> If you care to try it out, you will find that a method declaration of this 
> form:
> 
> - (void)doSomething: (did)sender;
> 
> is viewed by Interface Builder as an IBAction method to which you can connect 
> from some control . . .
> That's also a legacy feature.

Yup, I'd discovered that one as well but had ignored it as a bad dream ;-)

Regards

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


Fwd: NSMenu problems

2010-03-01 Thread slasktrattena...@gmail.com
This is the third time I'm posting this, but it seems it doesn't come
through. Apologies if they all show up at once.

-- Forwarded message --
Date: Sun, Feb 28, 2010 at 8:08 PM
Subject: NSMenu problems
To: cocoa-dev@lists.apple.com


Hello!

I've got a couple of problems with NSMenu.

1) All menu items have a custom view. Therefore the default action for
the menu item never gets called. Instead, I'm catching the mouse up
event in my custom view and call the appropriate selector from there.
This works fine. The problem I'm having is when navigating the menu
with the keyboard. When I select a menu item and hit return the menu
is simply dismissed. I have tried catching the keyboard event but have
no idea where it goes. It is not catched by the custom view, nor the
menu's delegate or app controller.

2) The menu has a custom search field as its first item. When I press
the arrow down key I'd like it to select the menu item under the
search field (this is a regular NSMenuItem). I can catch the moveDown:
command in the text field's

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
doCommandBySelector:(SEL)command

delegate method. But I cannot find any way to programmatically select
a menu item. I dug around in AppKit and found a private method named
_setHighlightedItem:informingDelegate:. This method does indeed seem
to change the selection, sort of: when I log the current selection it
reports the correct menu item. But it doesn't visually highlight this
item. I also tried simulating a arrow key down/up event (after setting
the first responder to the menu's window) but it didn't work either.

3) When typing in the search field, the menu is updated to show the
search results. This means the width of the menu is expanded to fit
the new items. But when I clear the search field and the menu items
are reset to their default values, the menu  doesn't shrink again.
Calling the deprecated sizeToFit method has no effect.

I hope you can help me out here. Thanks.

Kind regards,
Fabian
___

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

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

Help/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: Writing string to pasteboard on 10.5 causes crash

2010-03-01 Thread Abhinay Kartik Reddyreddy

On Mar 1, 2010, at 11:17 AM, jonat...@mugginsoft.com wrote:

> 
> On 1 Mar 2010, at 16:03, Martin Hewitson wrote:
> 
>> Dear list,
>> 
>> I have developed an app on SL but at all times compiled the app for 10.5. 
>> Today I got my hands on a leopard test machine to try out the app, and I get 
>> crashes due to various things. Some of these I've fixed, but I'm stuck at 
>> this one:
>> 
>> Part of the app has an NSTableView filled with strings. I am able to drag 
>> these strings from this 'library of strings' to another NSTextView. This all 
>> works find on SL, but on Leopard it sends the app either in to spinning 
>> beachball mode or it crashes. In the spinning beachball case I have to 
>> 'force quit' the app, and then I get a very long report which I can't 
>> extract any useful information from. The 'crash' actually happens before I 
>> reach a dragging destination, so it must be something at the source end. 
>> When the app crashes (rather than beachballs) I get the following (extract) 
>> crash report:
>> 
>> Thread 0 Crashed:
>> 0   com.apple.CoreFoundation 0x7fff8068e24f 
>> CFDictionaryRemoveValue + 63
>> 1   com.apple.AppKit 0x7fff80f3cec8 -[NSPasteboard 
>> setData:forType:] + 211
>> 2   com.apple.AppKit 0x7fff80f3cdcf -[NSPasteboard 
>> setString:forType:] + 122
>> 3   com.mhsoft.TeXnicle  0x000100015d7c -[LibraryController 
>> tableView:writeRowsWithIndexes:toPasteboard:] + 651
>> 4   com.apple.AppKit 0x7fff80ddda72 -[NSTableView 
>> _performDragFromMouseDown:] + 651
>> 5   com.apple.AppKit 0x7fff80ddbbf8 -[NSTableView 
>> mouseDown:] + 653
>> 6   com.apple.AppKit 0x7fff80d93783 -[NSWindow 
>> sendEvent:] + 5068
>> 7   com.apple.AppKit 0x7fff80d60d46 -[NSApplication 
>> sendEvent:] + 5089
>> 8   com.apple.AppKit 0x7fff80cbb562 -[NSApplication run] 
>> + 497
>> 9   com.apple.AppKit 0x7fff80c882f0 NSApplicationMain + 
>> 373
>> 10  com.mhsoft.TeXnicle  0x00015d40 main + 33
>> 11  com.mhsoft.TeXnicle  0x000117c0 start + 52
>> 
>> 
>> Here's the bit of code that writes the string to the pasteboard:
>> 
>> - (BOOL)tableView:(NSTableView *)aTableView 
>> writeRowsWithIndexes:(NSIndexSet *)rowIndexes 
>>   toPasteboard:(NSPasteboard*)pboard
>> {
>>  if (aTableView == itemsTable) {
>>  
>>  NSArray *items = [[contentsController arrangedObjects] 
>> objectsAtIndexes:rowIndexes];
>>  NSMutableArray *strings = [NSMutableArray array];
>>  for (NSDictionary *item in items) {
>>  [strings addObject:[item valueForKey:@"Code"]];
>>  }
>> //   id str = [[strings componentsJoinedByString:@"\n"] retain];
>>  id str = [strings componentsJoinedByString:@"\n"];
>>  NSLog(@"Writing to pboard: %@", str);
>>  return [pboard setString:str forType:NSStringPboardType];
>>  }
>>  
>>  return NO;
>> }
>> 
> Try preparing the pasteboard first with either of the following:
> 
> - (NSInteger)clearContents

looks like this is the available only on SL.  how to clear a pasteboard in 
Leopard ?

> - (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner

ownership could be a reason, the attempt to write to pasteboard is failing.

> 
> Regards
> 
> Jonathan Mitchell
> 
> Developer
> http://www.mugginsoft.com
> 
>> At one point I became unsure about the autoreleased string I create by 
>> 'componentsJoinedByString:' and if the pasteboard retains that or now, but I 
>> tested retaining and not, and it doesn't change anything. Can anyone see any 
>> obvious error? 
>> 
>> More info: this can really screw up the system pasteboard because sometimes 
>> after this crash I can no longer drag-n-drop text in any app and need to 
>> reboot to get things working again!
>> 
>> I'm hoping to avoid setting up a build environment on the Leopard machine, 
>> but maybe that's a little optimistic.
>> 
>> Any advice gratefully received.
>> 
>> I'd gladly send the app to anyone interested in running it. 
>> 
>> The SL working version can be found at: 
>> http://web.me.com/martinhewitson/BOBsoft/TeXnicle.html
>> 
>> Thanks in advance,
>> 
>> Martin
>> 
>> 
>> Martin Hewitson
>> Albert-Einstein-Institut
>> Max-Planck-Institut fuer 
>>   Gravitationsphysik und Universitaet Hannover
>> Callinstr. 38, 30167 Hannover, Germany
>> Tel: +49-511-762-17121, Fax: +49-511-762-5861
>> E-Mail: martin.hewit...@aei.mpg.de
>> WWW: http://www.aei.mpg.de/~hewitson
>> 
>> 
>> 
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderat

Re: Writing string to pasteboard on 10.5 causes crash

2010-03-01 Thread jonat...@mugginsoft.com

On 1 Mar 2010, at 16:43, Abhinay Kartik Reddyreddy wrote:
>>> 
>> Try preparing the pasteboard first with either of the following:
>> 
>> - (NSInteger)clearContents
> 
> looks like this is the available only on SL.  how to clear a pasteboard in 
> Leopard ?
Yes. Sorry about that. 10.6 only.
> 
>> - (NSInteger)declareTypes:(NSArray *)newTypes owner:(id)newOwner
> 
> ownership could be a reason, the attempt to write to pasteboard is failing.
> 
Docs for  declareTypes:owner: says

Mac OS X v10.5 and earlier: In Mac OS X v10.5 and earlier, this method is the 
first step in writing data to the pasteboard and must precede the messages that 
actually write the data. A declareTypes:owner: message essentially changes the 
contents of the receiver: It invalidates the current contents of the receiver 
and increments its change count.

I have previously omitted this when utilising the pasteboard and suffered 
accordingly.

Regards

Jonathan Mitchell

Developer
http://www.mugginsoft.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: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Joanna Carter
Hi Quincey

> You need to clarify your thinking. What you want (it appears) is a KVO 
> derived property in a certain class -- in this case, one whose value is 
> dependent on a property in a different class.

Actually, I don't really want a "dependent" property. All I want is a way to be 
able to pass a property on the main controller class to each of three derived 
array controllers, so that they can use that value to set a property on every 
new item added to the array controller.

At the moment, I am manually passing the value to each of the array controllers 
in the windowControllerDidLoadNib: method of the main controller.

This is fine but, since I will need to do the same thing in other scenarios, I 
wanted to create a derived array controller component that I could add to a NIB 
and setup in IB, rather than having to write the hookup code every time.

- (void)windowControllerDidLoadNib:(NSWindowController *)windowController 
{
  [super windowControllerDidLoadNib:windowController];

  [myExtendedArrayController setExtraProperty:[self extraProperty]];

  ...
}

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: Using CFMutableDictionaryRef

2010-03-01 Thread Matt Neuburg
On Sun, 28 Feb 2010 23:09:41 +, Alexander Hartner 
said:

>This is what I have come up with, but it's not working. The documentation
refers to a MultiTouchDemo which I can't find anywhere online.

Please do not hesitate to file a bug against the documentation! Referring to
a non-existent example is just plain wrong. It's particularly annoying in
this case because the code is rather difficult to understand out of context
(what is a "TransformGesture" and how did the code get hold of this list of
"transformGestures" to start with?). I think this must have been a WWDC
example that never made it into the canon.

m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

Help/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: NSMenu problems

2010-03-01 Thread Eric Schlegel

On Mar 1, 2010, at 8:33 AM, slasktrattena...@gmail.com wrote:

> 3) When typing in the search field, the menu is updated to show the
> search results. This means the width of the menu is expanded to fit
> the new items. But when I clear the search field and the menu items
> are reset to their default values, the menu  doesn't shrink again.
> Calling the deprecated sizeToFit method has no effect.

The Menu Manager won't shrink the menu until it's closed and reopened again. 
This is to avoid annoying visual distractions to the user as the menu resizes 
larger/smaller/larger/smaller.

-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: Audio APIs [Carbon is C++?]

2010-03-01 Thread Jens Alfke

On Feb 28, 2010, at 11:39 PM, Eagle Offshore wrote:

> There is no good reason not to have the base classes for AudioUnit be in 
> Objective-C rather than C++ other than the personal biases of certain 
> CoreAudio team members.

That's kind of insulting to those team members. The real reason is that most of 
the existing audio apps that needed to adopt these APIs were (are?) written in 
Carbon, not Cocoa. There was no way that Apple was going to tell developers 
like Bias, EMagic, Ableton and Propellerheads back in 2000 that they had to 
rewrite their apps — or even just their audio engines — from scratch in "some 
weirdo language".

Certainly nowadays (ten years later!) it would make more sense to have the 
media stuff in Objective-C. And I'm sure Apple's aware of that. They've chosen 
to start with QuickTime, and over the last few OS releases have modernized 
large swathes of it. Hopefully they'll work on the CoreAudio APIs next.

IMHO the worst problem with CoreAudio isn't what language it's in, but that the 
APIs don't form a coherent framework, rather a patchwork of complex procedural 
interfaces plus a pile of undocumented, mostly-unsupported and 
poorly-structured wrapper classes. Languages aren't a big deal — you should 
already be trying to learn a new language every year just to keep your mind 
flexible :)

—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


NSMenu problems

2010-03-01 Thread slasktrattena...@gmail.com
Hello!

I've got a couple of problems with NSMenu.

1) All menu items have a custom view. Therefore the default action for
the menu item never gets called. Instead, I'm catching the mouse up
event in my custom view and call the appropriate selector from there.
This works fine. The problem I'm having is when navigating the menu
with the keyboard. When I select a menu item and hit return the menu
is simply dismissed. I have tried catching the keyboard event but have
no idea where it goes. It is not catched by the custom view, nor the
menu's delegate or app controller.

2) The menu has a custom search field as its first item. When I press
the arrow down key I'd like it to select the menu item under the
search field (this is a regular NSMenuItem). I can catch the moveDown:
command in the text field's

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
doCommandBySelector:(SEL)command

delegate method. But I cannot find any way to programmatically select
a menu item. I dug around in AppKit and found a private method named
_setHighlightedItem:informingDelegate:. This method does indeed seem
to change the selection, sort of: when I log the current selection it
reports the correct menu item. But it doesn't visually highlight this
item. I also tried simulating a arrow key down/up event (after setting
the first responder to the menu's window) but it didn't work either.

3) When typing in the search field, the menu is updated to show the
search results. This means the width of the menu is expanded to fit
the new items. But when I clear the search field and the menu items
are reset to their default values, the menu  doesn't shrink again.
Calling the deprecated sizeToFit method has no effect.

I hope you can help me out here. Thanks.

Kind regards,
Fabian
___

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

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

Help/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: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Jens Alfke
In most cases there are better types to use than 'id' for an ivar. Using a 
specific class or protocol will get you type-checking. If it's something like a 
delegate and you don't care what class it is but will be sending one or two 
specific messages to it, you can create an @protocol containing those messages 
and declare the ivar as id.

—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: NSNull vs nil in NSManagedObject setValue: v forKey: k

2010-03-01 Thread Ben Trumbull

>> NSManagedObject* obj; // gets created somehow
>> 
>> [obj setValue: nil forKey: @"bar"]; // succeeds where NSDictionary fails
>> [obj setValue: [NSNull null] forKey: @"bar"]; // fails where NSDictionary 
>> succeeds
>> 
>> so - this is conceptually buggy thinking and the thoughtful developer could 
>> be forgiven for being VERY SURPRISED by this behavior that is NOT DOCUMENTED.

A review of 

 clearly documents the behavior.  Additional inferences beyond the 
documentation are unsupported.  "The NSNull class defines a singleton object 
used to represent null values in collection objects (which don’t allow nil 
values)"  None of the examples involve KVC.  There are no references to KVC in 
the related documentation.   NSNull isn't a Key Value Coding thing, this is an 
NSArray, NSSet, NSDictionary thing.  Nothing in the documentation implies 
otherwise.

Secondly, NSDictionary is untyped.  NSNull is valid for any key.  
NSManagedObject properties have an explicit type.  Values are expected to 
conform to the type specified for the property named by the key.  NSNull is not 
an NSString.  Your attempts otherwise are a basic violation of OOP. 

Thirdly, nil and NSNull are both valid values for typed NSManagedObject 
properties but they are not for NSDictionary.  In an NSDictionary, NSNull and 
nil must be equivalent because there are no other legal possibilities.  nil is 
never a valid value.  But for either transformable or transient NSManagedObject 
properties, both NSNull and nil are legal values.  Should we make it illegal to 
have optional properties that use NSNull ?  

In general, NSManagedObject does not perform value type coercion.  We chose 
this to balance several design criteria including detection of developer error 
(e.g. masking bad values), performance, and convenience (doing this yourself is 
trivial).  If enough developers feel another balancing would be more 
productive, we'd be happy to reevaluate that.  You should contribute by filing 
bugs.

- Ben

p.s. On an ancillary note, gratuitous use of NSNull outside of collections gets 
tedious & problematic.  Since NSNull != nil, all the client code then has to 
check multiple conditions, which this is easily forgotten, and then selector 
not recognized bugs crash apps because NSNull isn't the right class.

___

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

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

Help/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: Audio APIs [Carbon is C++?]

2010-03-01 Thread Paul Bruneau

On Mar 1, 2010, at 12:22 PM, Jens Alfke wrote:

IMHO the worst problem with CoreAudio isn't what language it's in,  
but that the APIs don't form a coherent framework, rather a  
patchwork of complex procedural interfaces plus a pile of  
undocumented, mostly-unsupported and poorly-structured wrapper  
classes. Languages aren't a big deal — you should already be trying  
to learn a new language every year just to keep your mind flexible :)


This actually makes me feel a lot better about my total inability to  
do anything at all in CoreAudio without relying almost completely upon  
the sample code. 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: Audio APIs [Carbon is C++?]

2010-03-01 Thread Kyle Sluder
On Mon, Mar 1, 2010 at 9:22 AM, Jens Alfke  wrote:
> IMHO the worst problem with CoreAudio isn't what language it's in, but that 
> the APIs don't form a coherent framework, rather a patchwork of complex 
> procedural interfaces plus a pile of undocumented, mostly-unsupported and 
> poorly-structured wrapper classes. Languages aren't a big deal — you should 
> already be trying to learn a new language every year just to keep your mind 
> flexible :)

Very much seconded. Thank goodness the engineers are so active and
helpful on coreaudio-api. Otherwise I think it would be impossible to
use PublicUtility successfully.

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


Customize UIBarButtonItem

2010-03-01 Thread Michael Abendroth
Hi,

I want to customize a UIBarButtonItem's background image. I have
already tried using the customView property (with a UIButton) , but it
does not work, instead it shows nothing. Searching around the web
gives some results, but none have worked for me.

Thanks for any input!
 - Michael
___

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

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

Help/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: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Quincey Morris
On Mar 1, 2010, at 08:48, Joanna Carter wrote:

> Actually, I don't really want a "dependent" property. All I want is a way to 
> be able to pass a property on the main controller class to each of three 
> derived array controllers, so that they can use that value to set a property 
> on every new item added to the array controller.
> 
> At the moment, I am manually passing the value to each of the array 
> controllers in the windowControllerDidLoadNib: method of the main controller.
> 
> This is fine but, since I will need to do the same thing in other scenarios, 
> I wanted to create a derived array controller component that I could add to a 
> NIB and setup in IB, rather than having to write the hookup code every time.
> 
> - (void)windowControllerDidLoadNib:(NSWindowController *)windowController 
> {
>  [super windowControllerDidLoadNib:windowController];
> 
>  [myExtendedArrayController setExtraProperty:[self extraProperty]];
> 
>  ...
> }

You want to "pass a property"? What does that mean? Never mind -- it's clear 
from your second paragraph that you mean "pass a value". I'm rudely pointing 
this out because using precise terms precisely is important, and you've led 
yourself astray multiple times in this thread by using them imprecisely.

If you don't really want a dependent property, then you certainly don't want a 
binding. Bindings are a more complicated version of a dependent property.

You can achieve what you said above very simply. The cheap version goes like 
this:

-- Add an IBOutlet to your NSArrayController subclass. Call it (say) 
owningWindowController. Or anything you like that doesn't conflict with an 
existing name.

-- When you instantiate one of these custom array controllers in IB, connect 
its owningWindowController outlet to File's Owner.

-- In your custom array controller's awakeFromNib method, do the following:

myExtraProperty = [owningWindowController extraProperty];

That's it.

The classy version is only slightly more complicated:

-- Define a protocol. Call it (say) extraPropertyProviderProtocol. The protocol 
contains just one thing, the "extraProperty" property definition.

-- Have your window controller formally adopt the protocol. (It already 
implements it.)

-- Declare your custom array controller outlet as IBOutlet 
NSObject* extraPropertyProvider.

-- Connect the outlet to File's Owner, as before.

-- In your custom array controller's awakeFromNib method, do the following:

myExtraProperty = extraPropertyProvider.extraProperty;

That way, File's Owner isn't unnecessarily constrained to be a particular class 
of object. It can be any object that conforms to the protocol.


___

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

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

Help/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: Customize UIBarButtonItem

2010-03-01 Thread Fritz Anderson
On 26 Feb 2010, at 10:21 AM, Michael Abendroth wrote:

> I want to customize a UIBarButtonItem's background image. I have
> already tried using the customView property (with a UIButton) , but it
> does not work, instead it shows nothing. Searching around the web
> gives some results, but none have worked for me.

I haven't tried this, so it's only something to experiment with...

Look upward in the class hierarchy. UIBarItem has an .image property.

— F

___

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

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

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

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


Re: [Solved]registering Defaults with NSUserDefaults not working

2010-03-01 Thread Gustavo Pizano
Ok I have finished with the defaults things, I think I got desperate after the 
first step which was setting the Application defaults, and I didn't realize I 
needed to complete the second step which is allow the user to set his/defaults, 
so  after I did so,, all was fine, the .plist in the library was created 
properly and all tis working like a  a charm.

Thanks

Gustavo


On Mar 1, 2010, at 4:47 PM, Gustavo Pizano wrote:

> 
> On Mar 1, 2010, at 4:07 PM, Keary Suska wrote:
> 
>> On Mar 1, 2010, at 3:01 AM, Gustavo Pizano wrote:
>> 
>>> [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
>>> if([[NSUserDefaults standardUserDefaults] synchronize])NSLog(@"Could Save");
>> 
>> -registerDefaults: does not actually change default values, it simply sets 
>> what the default values should be in certain cases. You can read 
>> NSUserDefaultsController about ways to use default values. If you delete 
>> your plist preference file, then re-run, you might see different results. 
>> You might be happier in the long wrong if you follow the docs and have all 
>> of your application defaults in app delegate's +initialize, or as a 
>> pre-defined plist in your project. You also don't need to call -synchronize 
>> if your app will terminate normally (saving defaults is one of the exit 
>> functions).
>> 
> Well I did as the Apple example I mentioned, they where doing that in the 
> applicationDidFinishLaunch. Nevertheless,  so .. I have my .plist in the 
> resources with all the values of the colors for the gradients, so from there 
> is where Im reading to create the defaults gradients and I want to save them 
> into the userDefaults,  then when the User click the preferences menu item 
> he/she can choose different colors, then I will generate internally the new 
> gradients  then use the [[NSUserDefaults standarUSerDefaults] 
> setObjectForKey:kGradientKey]. If the user click the button restore defaults 
> I will generate the defaults values form the .plist I have in the resources 
> folder, and again set the gradient data.
> 
> I deleted the com.mycompany.myapp, reloaded the application and no files are 
> generated again, shall i run it on release mode?.. :S. 
> 
> So I will put this bunch of code on the +initialize, and Check the 
> NSUserDefaultsController, so see what other ideas it will give me as you 
> suggested.
> 
> Thanks for the help
> 
> Gustavo
> 
> 
>> HTH,
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
> 

___

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

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

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

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


Re: NSMenu problems

2010-03-01 Thread slasktrattena...@gmail.com
OK, I can live with this. Thanks.

On Mon, Mar 1, 2010 at 6:17 PM, Eric Schlegel  wrote:
>
> On Mar 1, 2010, at 8:33 AM, slasktrattena...@gmail.com wrote:
>
>> 3) When typing in the search field, the menu is updated to show the
>> search results. This means the width of the menu is expanded to fit
>> the new items. But when I clear the search field and the menu items
>> are reset to their default values, the menu  doesn't shrink again.
>> Calling the deprecated sizeToFit method has no effect.
>
> The Menu Manager won't shrink the menu until it's closed and reopened again. 
> This is to avoid annoying visual distractions to the user as the menu resizes 
> larger/smaller/larger/smaller.
>
> -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: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Joanna Carter
Hi Quincey

> You want to "pass a property"? What does that mean? Never mind -- it's clear 
> from your second paragraph that you mean "pass a value". I'm rudely pointing 
> this out because using precise terms precisely is important, and you've led 
> yourself astray multiple times in this thread by using them imprecisely.

Hey, I'm an experienced consultant who is also a member of TeamB (which is the 
techie/wizzy bunch who support Borland/Inprise/CodeGear/Embarcadero products. I 
have a brain the size of a planet and you still expect me to make cogent sense 
of the English language? 

> The classy version is only slightly more complicated:
> 
> -- Define a protocol. Call it (say) extraPropertyProviderProtocol. The 
> protocol contains just one thing, the "extraProperty" property definition.
> 
> -- Have your window controller formally adopt the protocol. (It already 
> implements it.)
> 
> -- Declare your custom array controller outlet as IBOutlet 
> NSObject* extraPropertyProvider.
> 
> -- Connect the outlet to File's Owner, as before.
> 
> -- In your custom array controller's awakeFromNib method, do the following:
> 
>   myExtraProperty = extraPropertyProvider.extraProperty;
> 
> That way, File's Owner isn't unnecessarily constrained to be a particular 
> class of object. It can be any object that conforms to the protocol.

Doh!!! In non-Objective-C words, declare an interface and use that to surface 
the property/value on the main controller. Thank you so much for making a 
middle-aged woman happy ;-)

Having designed my own MVP and OPF frameworks for .NET, I'm still making the 
transition to Mac development. The biggest hurdle is just the shear size of the 
Cocoa frameworks. Oh, and getting used to the "dynamic" nature of Objective-C.

Can I just indulge by asking whether the protocol, in this situation, would 
best be formal or informal?

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: Audio APIs [Carbon is C++?]

2010-03-01 Thread Roni Music

There was a similar discussion on the coreaudio-api list a year ago,
it ended like this with an answer from one of the CoreAudio engineers:


From: William Stewart 



I don't want a full-blown discussion here, but from everything we've
seen (including the guts of obj_message send) ObjC is completely
inappropriate for time-constrained, hard deadline driven programming.
The addition of garbage collection makes this more so.



Bill


///



On Feb 28, 2010, at 11:39 PM, Eagle Offshore wrote:

There is no good reason not to have the base classes for AudioUnit be in 
Objective-C rather

than C++ other than the personal biases of certain CoreAudio team members.

That's kind of insulting to those team members. The real reason is that 
most of the existing audio apps that needed to adopt these APIs were 
(are?) written in Carbon, not Cocoa. There was no way that Apple was going 
to tell developers like Bias, EMagic, Ableton and Propellerheads back in 
2000 that they had to rewrite their apps - or even just their audio 
engines - from scratch in "some weirdo language".


Certainly nowadays (ten years later!) it would make more sense to have the 
media stuff in Objective-C. And I'm sure Apple's aware of that. They've 
chosen to start with QuickTime, and over the last few OS releases have 
modernized large swathes of it. Hopefully they'll work on the CoreAudio 
APIs next.


IMHO the worst problem with CoreAudio isn't what language it's in, but 
that the APIs don't form a coherent framework, rather a patchwork of 
complex procedural interfaces plus a pile of undocumented, 
mostly-unsupported and poorly-structured wrapper classes. Languages aren't 
a big deal - you should already be trying to learn a new language every 
year just to keep your mind flexible :)


-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


IsReadableFileAtPath

2010-03-01 Thread gMail.com
Hi,
I need to check whether a file or a symlink could be really copied.
I have just seen that the Cocoa API isReadableFileAtPath traverses the
symlink, so, in case the target file is not readable, my app doesn't copy
the symlink, while the Finder can properly do. So my app does wrong.

The question is:
How can I understand whether a file or symlink can really be copied?
I have seen that isReadableFileAtPath uses the C command "access" which
indeed traverses the symlink. So I cannot use it. So, any idea?
And I wouldn't use the Carbon APIs because I need to compile for 64 bit.
Thank you.

Leonardo


___

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

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

Help/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: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Quincey Morris

On Mar 1, 2010, at 11:00, Joanna Carter wrote:

> I have a brain the size of a planet and you still expect me to make cogent 
> sense of the English language? 

No, planet-brain wins. ;)

> Can I just indulge by asking whether the protocol, in this situation, would 
> best be formal or informal?

With Objective-C 2.0, I can't think of any reason to stick with an informal 
protocol. Formal protocols mean actual compile-time checking, and they rarely 
blow up in your face any more.


___

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

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

Help/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: IsReadableFileAtPath

2010-03-01 Thread Nick Zitzmann

On Mar 1, 2010, at 12:20 PM, gMail.com wrote:

> I need to check whether a file or a symlink could be really copied.
> I have just seen that the Cocoa API isReadableFileAtPath traverses the
> symlink, so, in case the target file is not readable, my app doesn't copy
> the symlink, while the Finder can properly do. So my app does wrong.
> 
> The question is:
> How can I understand whether a file or symlink can really be copied?

Maybe lstat() would better suit your needs?

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


NSXMLDocument outputs numbers in exponential format?

2010-03-01 Thread Colin Cornaby
I'm working with NSXMLDocument and serializing it to a file... The issue is the 
serialized output contains numbers in exponential formal, i.e. 
installKBytes="1.744E3". Other programs aren't parsing this correctly... Is 
there any way to modify the output to just format the numbers normally?
___

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

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

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

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


NSCollectionView deselection

2010-03-01 Thread Thomas Davie
Hi,

I have, after much struggling with the documentation, managed to create an 
NSCollectionView that displays all the items I want it to.  However, selection 
isn't quite working right.

When the user clicks on item A, setSelected:YES is sent to the 
NSCollectionViewItem subclass for A.  This pleases me :)
When the user clicks on item B, setSelected:YES is sent to the 
NSCollectionViewItem subclass for B.  This pleases me too :).
However, when the user clicks on item B after clicking on item A, 
setSelected:NO is *not* sent to the NSCollectienViewItem subclass for A.  This 
displeases me greatly :(.

Is there some way I can get my NSCollectionView to tell me when the user 
deselects items?

Thanks

Tom Davie

___

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

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

Help/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 NSCell

2010-03-01 Thread Tilo Villwock
Hi,

I've created a custom NSCell Object to layout some different text attributes of 
a custom data object in a NSTableView, but for some reason all the attributes 
of the different data objects are only displayed in the first row and nothing 
at all in the other rows. Every row receives a separate data object via the 
NSTableViewDataSource methods.
In applicationDidFinishLaunching: I created an instance of my custom NSCell 
class and put it in place for the right column.
Any thoughts what might cause this behaviour? I don't assume it is necessary to 
create a new instance of my NSCell class for every row I have, right?

Thanks,

Tilo___

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

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

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

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


Re: Custom NSCell

2010-03-01 Thread Nick Zitzmann

On Mar 1, 2010, at 12:45 PM, Tilo Villwock wrote:

> I've created a custom NSCell Object to layout some different text attributes 
> of a custom data object in a NSTableView, but for some reason all the 
> attributes of the different data objects are only displayed in the first row 
> and nothing at all in the other rows. Every row receives a separate data 
> object via the NSTableViewDataSource methods.
> In applicationDidFinishLaunching: I created an instance of my custom NSCell 
> class and put it in place for the right column.
> Any thoughts what might cause this behaviour? I don't assume it is necessary 
> to create a new instance of my NSCell class for every row I have, right?

Does your cell subclass support NSCopying?

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: Trouble with core data and Save As

2010-03-01 Thread Sean McBride
On 2/27/10 4:50 PM, Gideon King said:

>I'm having another look at an issue I posted about a couple of weeks
>ago, where Save As was causing an error.

I've had quite a few bugs with Save As.  One was fixed in 10.6.2.  What
OS are you using?

--

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


___

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

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

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

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


Re: Custom NSCell

2010-03-01 Thread Tilo Villwock
Well, since I'm subclassing NSCell and only override the method 
drawInteriorWithFrame: why is there a need to override copyWithZone: as well? I 
don't store any data within the Class.

Am 01.03.2010 um 20:59 schrieb Nick Zitzmann:

> 
> On Mar 1, 2010, at 12:45 PM, Tilo Villwock wrote:
> 
>> I've created a custom NSCell Object to layout some different text attributes 
>> of a custom data object in a NSTableView, but for some reason all the 
>> attributes of the different data objects are only displayed in the first row 
>> and nothing at all in the other rows. Every row receives a separate data 
>> object via the NSTableViewDataSource methods.
>> In applicationDidFinishLaunching: I created an instance of my custom NSCell 
>> class and put it in place for the right column.
>> Any thoughts what might cause this behaviour? I don't assume it is necessary 
>> to create a new instance of my NSCell class for every row I have, right?
> 
> Does your cell subclass support NSCopying?
> 
> 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: NSXMLDocument outputs numbers in exponential format?

2010-03-01 Thread Fritz Anderson
On 1 Mar 2010, at 1:37 PM, Colin Cornaby wrote:

> I'm working with NSXMLDocument and serializing it to a file... The issue is 
> the serialized output contains numbers in exponential formal, i.e. 
> installKBytes="1.744E3". Other programs aren't parsing this correctly... Is 
> there any way to modify the output to just format the numbers normally?

I see this in the documentation for -[NSXMLNode setObjectValue:] (which I 
assume you're passing an NSNumber into):

==
Note: Prior to Mac OS X v 10.6 setObjectValue: would improperly and 
inconsistently format objects that were NSNumber instances. Applications linked 
on Mac OS X 10.6 or later will use correct scientific notation for all 
NSNumbers passed to setObjectValue:.

If you require a particular format for any value in your XML document, you 
should format the data yourself as a string and then use setStringValue: to set 
the value. This guarantees that the text generated is in a format you control 
directly.
==

So if your consumers don't like scientific notation, use an NSNumberFormatter 
to get the preferred format, and set the string value yourself.

The same applies, I imagine, to -[NSXMLElement setAttributesAsDictionary:].

Possibly I'm misunderstanding you. You really don't say how you're putting your 
numbers into the document.

— F

___

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

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

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

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


Re: IsReadableFileAtPath

2010-03-01 Thread Jens Alfke

On Mar 1, 2010, at 11:20 AM, gMail.com wrote:

> I have just seen that the Cocoa API isReadableFileAtPath traverses the
> symlink, so, in case the target file is not readable, my app doesn't copy
> the symlink, while the Finder can properly do. So my app does wrong.

-isReadableFileAtPath is just a convenience. If you don't want to traverse 
symlinks, call -fileAttributesAtPath:traverseLink: and use NO for the second 
parameter.

> How can I understand whether a file or symlink can really be copied?

You can't preflight file operations with 100% accuracy, because there's always 
a race condition — the file's permissions could be modified in between checking 
permission and doing the actual copy. You should still do the preflighting if 
it helps the user experience (by disabling a button, for example); but always 
be prepared to handle errors from the actual operation itself. 

If you don't need preflighting for your UI, just skip it. In other words, don't 
do the following:
if (fileIsCopyable(file))
copyFile(file);
Instead just call copyFile() and handle any error it returns.

> And I wouldn't use the Carbon APIs because I need to compile for 64 bit.

The Carbon File Manager API is available in 64-bit, and it's perfectly 
appropriate to use it in Cocoa apps. It's only a subset of Carbon High-Level 
Toolbox APIs that aren't available in 64-bit (and you wouldn't be using those 
in a Cocoa app anyway.)

—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: Trouble with core data and Save As

2010-03-01 Thread Gideon King
10.6.2. I did receive a suggestion from Jerry Krinock over the weekend to try 
switching to an XML store and seeing whether that fixed the problem, so I could 
narrow it down as to what was causing the problem, but haven't had time to look 
into that yet (I have a lot of custom code for transformable attributes, so I 
don't know whether this will work for me). Am planning to look into this whole 
thing further today.

Gideon

On 02/03/2010, at 6:06 AM, Sean McBride wrote:

> 
> I've had quite a few bugs with Save As.  One was fixed in 10.6.2.  What
> OS are you using?
> 

___

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

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

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

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


[Moderator] Re: Audio APIs [Carbon is C++?]

2010-03-01 Thread Scott Anguish

On Mar 1, 2010, at 2:05 PM, Roni Music wrote:

> There was a similar discussion on the coreaudio-api list a year ago,

And with this, I think we can close this discussion as no longer productive.

Greg Parker’s answer earlier in the thread should likely be considered 
definitive.


scott
moderator

___

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

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

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

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


XCode's Special Buttons

2010-03-01 Thread Jean-Henri Duteau
Okay, simple question here...

I'd like to replicate the + and - buttons that are found in XCode's Data 
modeller view.  This is the one where you click on '+' and it shows a menu of 
attribute/property/relationship.  Is it a simple button that's scaled down and 
is combined to a pop-up?  I've tried a few abortive attempts to recreate it but 
haven't had success.  I'm sure if I'm just given a hint as to how it's done, I 
could make it happen.  Of course, pointers to sample code is always nice.

Thanks,

Jean___

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

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

Help/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: Where in the MVC should my code go?

2010-03-01 Thread Chase Meadors

Just my 2 cents, but I see these possibilities:

1. If it's a fairly custom application, small, or simple, just combine  
the code with the view since it's likely that the view will not need  
to be particularly flexible or used over and over.


2. On the other hand, if you want the view to be more independent and  
flexible as according to MVC, you have more options. If you're binding  
the model to the view, you can simply use a custom NSValueTransformer  
class to change your model attribute to an array of strings. Or you  
can simply factor the code into the view controller in any way you wish.


On Feb 28, 2010, at 1:34 AM, Jean-Henri Duteau wrote:



On 2010-02-28, at 12:23 AM, Matthew Lindfield Seager wrote:

On Sunday, February 28, 2010, Jean-Henri Duteau > wrote:
I don't have a good reason to not put it into the view other than  
pragmatic.  I can give the controller a bunch of attributes and  
bind the view's controls to those attributes, as opposed to  
programatically creating the strings in the view.


For small applications or simple situations it is not uncommon to
combine two roles into the one object (e.g. combining controller &
view functions or controller & model functions into one object).

I understand that.  I've already split the functions - I have a  
View, a ViewController, and a Model.  My question is more one of  
where does this code reside.  I'm confident that it's not model code  
- the model could care less about these strings.  I'm not as  
confident with my existing choice of the controller and was hoping  
someone could come swooping in and say "of course that is view code  
and here is why, you fool!" or "rest easy, young padawan, that is  
obvious controller code".





Advice?


Read Cocoa Design Patterns by Buck & Yacktman... It's excellent
reading (& not just for its treatment of MVC).


Thanks.  I have that book and have read it a couple of times.  In my  
opinion, it is one of the best programming books around.  By  
explaining the patterns that underly the various Cocoa APIs, it  
really allows anyone coming from outside of Cocoa to understand it.


Having said that, I was hoping for more practical advice as I  
indicated above. *smile*


BTW, I've already considered a Transformer.  The problem with that  
is one of code bloat - I have multiple fields on the view that are  
derived from this one attribute.  I haven't figured out a way at  
design time in IB to make one transformer handle the different  
transformations.


Jean___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/c.m.cocoadev%40gmail.com

This email sent to c.m.cocoa...@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


Catching double click (any mouse events) in an NSTableView

2010-03-01 Thread Eric Giguere
Hi all

I'm a newbie with the Mac programming and been trying for a couple of hours to 
do something that should be straightforward, no success so I'm asking the Pros 
for some help :).

I'm have a small application, using Core Data, that shows in the Main Window a 
list of entities. I'm trying to trap mouse events to have another window opened 
when double clicking on an item. 
I created a controller for my window and have it override the mouseDown: , 
works but only for mouse event it the window itself, not its controls.
I did the same thing for the TableView, created a controller for it. But on 
this one, no mouseDown events ever get sent.

- (void)mouseDown:(NSEvent *)theEvent {
NSLog(@"Mouse Event received in the list view!!!");
//  [theEvent: 
}

I tried then on this same TableView controller to have the delegate method:
- (void)textView:(NSTextView *)aTextView clickedOnCell:(id < 
NSTextAttachmentCell >)cell inRect:(NSRect)cellFrame 
atIndex:(NSUInteger)charIndex {
NSLog(@"Mouse click event in the text view...");

}

Failed again, this doen't do anything.
But, if in this class I declare a delegate for a method directly on the 
TableView

- (void) tableView:(NSTableView*)tableView 
mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn {
NSLog(@"Mouse event in the table view...");
}


Now this method gets called!

So guys, what am I getting wrong here? How can I catch the mouse click in a 
TableList? I guess when doing it correctly for this one, it will be the same 
for all other controls.

Any help will be greatly appreciated, Thank you very much!

Eric





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

Drawing an NSView into an NSGraphicsContext

2010-03-01 Thread Brian Postow
I have a CGContext, which I can turn into an NSGraphicsContext. I have an 
NSWindow with a clipRect for the context.

I want to put a scrollview into the context and then some other view into the 
scrollview so I can put an image into it... However, I can't figure out how to 
attach the scrollview into the context.

Eventually the view will probably be coming from a nib, but I don't see how 
that would matter.

I've seen this thread, 
(http://lists.apple.com/archives/quartz-dev/2006/Nov/msg00010.html) But they 
seem to leave off the step of how to attach the view into the context, unless 
there's something obvious I'm missing.

The reason I'm in this situation is that I'm writing a Mozilla Plugin. The 
browser gives me a CGContext (Quartz) and a WindowRef (QuickDraw). I can turn 
the CGContext into an NSGraphicsContext, and I can turn the windowRef into an 
NSWindow. From another data structure I also have the clipping rectangle...

I'm trying to draw an image into that context, with scrollbars as needed, and 
buttons and other UI elements... so I need (want) an NSView...

I'm currently thinking that I can't actually really do this the way I want to. 
My current plan is to make a NIB with the two views (NSScroll and IKImageVIew 
probably) and instantiate that. Then, draw it into the context with some method 
that takes a snapshot of the view. At that point I'll need to capture all 
events myself and translate them back to the view(s) and re-snapshot the view 
to put it back in the context.

Is there a better way to do this?

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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

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

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

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


[NSString characterAtIndex:] -> [NSString stringWithCString:encoding:]

2010-03-01 Thread Gabriel Fernandez
Hi, I'm having trouble with NSString - I'm capturing NSTextField edits and 
analyzing the typed (uni-)chars:

{
int bufsize = 3*sizeof(unichar) ;
static unichar *buf = nil ;
if( nil == buf )
{
buf = (unichar*) malloc( bufsize ) ;
if( nil != buf )
{
buf[ 2 ] = 0 ;
} else {
NSLog(@"textDidChange: malloc error");
return ;
}

}

NSString * s = [textField stringValue] ;

// could put this in a loop, but I'm only handling 2 characters, so...

if( 0 < [s length] )
{
buf[0] = [s characterAtIndex:0];
buf[1] = 0 ;
}

if( 1 < [s length] )
{
buf[1] = [s characterAtIndex:1];
}

// buf is set to the character string properly...

s = [NSString stringWithCString:(const char *)buf encoding: 
NSUnicodeStringEncoding] ;

NSInteger s_len = [s length]; //s_len is always zero
}

if I change the encoding: to ascii, I get one character in the new NSString, as 
I'd expect, but with Unicode encoding, I get no characters - WHY?!

Thanks In Advance,

Gabe



Gabriel Fernandez
Wheel Software

___

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

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

Help/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: IsReadableFileAtPath

2010-03-01 Thread Kevin Perry
In general, this kind of check-then-do pattern opens the door for file system 
race conditions. The documentation for this method (and related methods) has a 
little more information about this in the "Note" section.

Could you just try to copy the symlink and then deal with any errors that 
result?

-Kevin

On Mar 1, 2010, at 11:20 AM, gMail.com wrote:

> Hi,
> I need to check whether a file or a symlink could be really copied.
> I have just seen that the Cocoa API isReadableFileAtPath traverses the
> symlink, so, in case the target file is not readable, my app doesn't copy
> the symlink, while the Finder can properly do. So my app does wrong.
> 
> The question is:
> How can I understand whether a file or symlink can really be copied?
> I have seen that isReadableFileAtPath uses the C command "access" which
> indeed traverses the symlink. So I cannot use it. So, any idea?
> And I wouldn't use the Carbon APIs because I need to compile for 64 bit.
> Thank you.
> 
> Leonardo
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kperry%40apple.com
> 
> This email sent to kpe...@apple.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: [NSString characterAtIndex:] -> [NSString stringWithCString:encoding:]

2010-03-01 Thread Nick Zitzmann

On Mar 1, 2010, at 10:25 AM, Gabriel Fernandez wrote:

> if I change the encoding: to ascii, I get one character in the new NSString, 
> as I'd expect, but with Unicode encoding, I get no characters - WHY?!

The method you're using takes a buffer of 1-byte characters, not 2-byte 
characters. Use +stringWithCharacters:length: if you need to deal with 2-byte 
Unicode characters.

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: Is there any Cocoa API (or other way) to determine if an application is running in a VNC or ARD session?

2010-03-01 Thread Jonathan Hendry

Checking on my lsof -i suggestion now that I'm at work...

I just set up a screen sharing session from my laptop to another  
machine.


lsof -i on my laptop produced the following output:

AppleVNCS 19770  jon5u  IPv6  0x69d9b2c  0t0  TCP *:vnc-server  
(LISTEN)
AppleVNCS 19770  jon6u  IPv6  0x69d85a8  0t0  TCP  
dhc016942.med.harvard.edu:vnc-server->blur.med.harvard.edu:49152  
(ESTABLISHED)
Screen19773  jon4u  IPv4  0x77a6270  0t0  TCP  
dhc016942.med.harvard.edu:64931->blur.med.harvard.edu:vnc-server  
(ESTABLISHED)


I didn't have to run lsof as root.

After ending the screen sharing session on the remote computer, lsof - 
i on my mac produces this output:


AppleVNCS 19770  jon5u  IPv6  0x69d9b2c  0t0  TCP *:vnc-server  
(LISTEN)


The AppleVNCS 'ESTABLISHED' socket is gone, as is the 'Screen' process  
and its socket, leaving just the screen sharing listening socket.


Apparently the screen-sharing processes run as whoever is logged in at  
the console.


If you want to find out if there's an active VNC session in progress,  
this appears to be a reasonable lead on how to do it, although it  
won't tell you who's controlling the computer at a given time or let  
you distinguish remote input from local input.

___

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

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

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

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


RE: Is there any Cocoa API (or other way) to determine if an application is running in a VNC or ARD session?

2010-03-01 Thread Joe Jones
Great, thanx!

From: Jonathan Hendry [mailto:jonhen...@mac.com]
Sent: Monday, March 01, 2010 3:15 PM
To: Joe Jones
Cc: cocoa-dev@lists.apple.com Developers
Subject: Re: Is there any Cocoa API (or other way) to determine if an 
application is running in a VNC or ARD session?

Checking on my lsof -i suggestion now that I'm at work...

I just set up a screen sharing session from my laptop to another machine.

lsof -i on my laptop produced the following output:

AppleVNCS 19770  jon5u  IPv6  0x69d9b2c  0t0  TCP *:vnc-server (LISTEN)
AppleVNCS 19770  jon6u  IPv6  0x69d85a8  0t0  TCP 
dhc016942.med.harvard.edu:vnc-server->blur.med.harvard.edu:49152 (ESTABLISHED)
Screen19773  jon4u  IPv4  0x77a6270  0t0  TCP 
dhc016942.med.harvard.edu:64931->blur.med.harvard.edu:vnc-server (ESTABLISHED)

I didn't have to run lsof as root.

After ending the screen sharing session on the remote computer, lsof -i on my 
mac produces this output:

AppleVNCS 19770  jon5u  IPv6  0x69d9b2c  0t0  TCP *:vnc-server (LISTEN)

The AppleVNCS 'ESTABLISHED' socket is gone, as is the 'Screen' process and its 
socket, leaving just the screen sharing listening socket.

Apparently the screen-sharing processes run as whoever is logged in at the 
console.

If you want to find out if there's an active VNC session in progress, this 
appears to be a reasonable lead on how to do it, although it won't tell you 
who's controlling the computer at a given time or let you distinguish remote 
input from local input.
___

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

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

Help/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: NSWindow - makeKeyAndOrderFront problem

2010-03-01 Thread Matthew Lindfield Seager
On Monday, March 1, 2010, Andreas Mayer  wrote:
> Try dragging something onto the iTunes source list. iTunes will import it, 
> but will not activate itself.

Apples & Oranges... iTunes is (was?) a library application more than a
player. It also has origins in audio, not video. Then again I think
the "correct" behaviour is dictated by the principle of least
surprise...

If I've told a video player to start playing files on open I would
generally expect the player to bring itself to the front after
specifically dropping a media file onto it.

With an audio player I'd be a little surprised if it took over my
computer (unless the app requires visual interaction). I don't need
the app to be frontmost to hear it through the speakers.

The right choice for you and your users can't be answered definitively
by a mailing list.

For more "guidance" see what other popular or Apple apps do (e.g.
QuickTime Player, etc) or do some usability testing with some target
users.

Matt
___

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

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

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

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


Re: Is there any Cocoa API (or other way) to determine if an application is running in a VNC or ARD session?

2010-03-01 Thread Ken Ferry
If you are going to look at stuff like that, please make sure your
application is still usable if it stops working.  You're looking at
implementation details, not API.  They can break between OS releases.

-Ken

On Mon, Mar 1, 2010 at 3:16 PM, Joe Jones  wrote:

> Great, thanx!
>
> From: Jonathan Hendry [mailto:jonhen...@mac.com]
> Sent: Monday, March 01, 2010 3:15 PM
> To: Joe Jones
> Cc: cocoa-dev@lists.apple.com Developers
> Subject: Re: Is there any Cocoa API (or other way) to determine if an
> application is running in a VNC or ARD session?
>
> Checking on my lsof -i suggestion now that I'm at work...
>
> I just set up a screen sharing session from my laptop to another machine.
>
> lsof -i on my laptop produced the following output:
>
> AppleVNCS 19770  jon5u  IPv6  0x69d9b2c  0t0  TCP *:vnc-server
> (LISTEN)
> AppleVNCS 19770  jon6u  IPv6  0x69d85a8  0t0  TCP
> dhc016942.med.harvard.edu:vnc-server->blur.med.harvard.edu:49152(ESTABLISHED)
> Screen19773  jon4u  IPv4  0x77a6270  0t0  TCP
> dhc016942.med.harvard.edu:64931->blur.med.harvard.edu:vnc-server
> (ESTABLISHED)
>
> I didn't have to run lsof as root.
>
> After ending the screen sharing session on the remote computer, lsof -i on
> my mac produces this output:
>
> AppleVNCS 19770  jon5u  IPv6  0x69d9b2c  0t0  TCP *:vnc-server
> (LISTEN)
>
> The AppleVNCS 'ESTABLISHED' socket is gone, as is the 'Screen' process and
> its socket, leaving just the screen sharing listening socket.
>
> Apparently the screen-sharing processes run as whoever is logged in at the
> console.
>
> If you want to find out if there's an active VNC session in progress, this
> appears to be a reasonable lead on how to do it, although it won't tell you
> who's controlling the computer at a given time or let you distinguish remote
> input from local input.
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to kenfe...@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


Menu Items

2010-03-01 Thread David Blanton
I connected a menu item to an action in First Responder. The action is  
defined in a view.


This, apparently, does not define the Target as I put validateMenuItem  
in the same view as the action but it is not called.


So, how does one define the Target?

The view and the Menu Item are in different nib files.

I really need to get a handle on how the best way to work with menus.

-db

___

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

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

Help/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: XCode's Special Buttons

2010-03-01 Thread Kevin Wojniak
It's probably an NSPopUpButton subclass, with a custom NSPopUpButtonCell 
subclass to change its appearance. I don't think IB lets you create custom 
popup buttons that small, so you'd probably have to either use a standard 
button or a custom view, and then set the class name and finish up any other 
configurations in the subclass's awakeFromNib/initWithFrame/initWithCoder/etc 
methods.

Kevin


On Mar 1, 2010, at 2:25 PM, Jean-Henri Duteau wrote:

> Okay, simple question here...
> 
> I'd like to replicate the + and - buttons that are found in XCode's Data 
> modeller view.  This is the one where you click on '+' and it shows a menu of 
> attribute/property/relationship.  Is it a simple button that's scaled down 
> and is combined to a pop-up?  I've tried a few abortive attempts to recreate 
> it but haven't had success.  I'm sure if I'm just given a hint as to how it's 
> done, I could make it happen.  Of course, pointers to sample code is always 
> nice.
> 
> Thanks,
> 
> Jean___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com
> 
> This email sent to kain...@kainjow.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: Where in the MVC should my code go?

2010-03-01 Thread Jean-Henri Duteau

On 2010-03-01, at 3:20 PM, Chase Meadors wrote:

> 2. On the other hand, if you want the view to be more independent and  
> flexible as according to MVC, you have more options. If you're binding  
> the model to the view, you can simply use a custom NSValueTransformer  
> class to change your model attribute to an array of strings. Or you  
> can simply factor the code into the view controller in any way you wish.

In the end, that's what I ended up doing.  I created a Value Transformer and in 
my ViewController, registered the 15 different instances of the transfomer and 
gave them different names.  This ends up being the best separation of concerns 
- neither the view nor the model know about these transformations and I have 
one class to consult to change the code.

Thanks to everyone who contributed suggestions.  The process of reading the 
responses and understanding them allowed me to finalize on my solution.

Jean___

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

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

Help/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: Menu Items

2010-03-01 Thread Gideon King
There is no target when you connect to the first responder - in effect the 
target is determined at runtime by the window order, view hierarchies, 
controllers etc. I suggest you read up on the responder chain. Once you 
understand it, it's very logical and powerful.

HTH

Gideon

On 02/03/2010, at 9:47 AM, David Blanton wrote:

> I connected a menu item to an action in First Responder. The action is 
> defined in a view.
> 
> This, apparently, does not define the Target as I put validateMenuItem in the 
> same view as the action but it is not called.
> 
> So, how does one define the Target?
> 
> The view and the Menu Item are in different nib files.
> 
> I really need to get a handle on how the best way to work with menus.
> 
> -db

___

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

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

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

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


Re: Custom NSCell

2010-03-01 Thread Sean McBride
On 3/1/10 8:45 PM, Tilo Villwock said:

>In applicationDidFinishLaunching: I created an instance of my custom
>NSCell class and put it in place for the right column.

Could you elaborate?

I have found that I needed to set the custom cell in IB.  You can drag a
custom cell from the library to the tableview's column then set the
class name to your cell subclass.  But you can only do that in IB 3.2,
not earlier.

>Any thoughts what might cause this behaviour? I don't assume it is
>necessary to create a new instance of my NSCell class for every row I
>have, right?

No, NSTableView copies them.

--

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


___

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

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

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

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


Re: Menu Items

2010-03-01 Thread Graham Cox

On 02/03/2010, at 10:47 AM, David Blanton wrote:

> I connected a menu item to an action in First Responder. The action is 
> defined in a view.
> 
> This, apparently, does not define the Target as I put validateMenuItem in the 
> same view as the action but it is not called.
> 
> So, how does one define the Target?
> 
> The view and the Menu Item are in different nib files.
> 
> I really need to get a handle on how the best way to work with menus.


You are doing it right. First Responder defines the target as the first 
responder currently within the app. When that's your view, its action and menu 
validation method will be called; when that's not your view, they won't.

So it sounds as if your view is not becoming first responder, rather than a 
problem with the menu itself.

Note that the ability to click a view and have it respond to mouse events does 
not indicate first responder is that view - FR really pertains to keyboard 
input and other context-sensitive UI like menus. Your view must return YES to 
-acceptsFirstResponder: (inherited from NSResponder) which is NO by default. 
You'll probably also want to set up how that view fits in with other potential 
responders which involves hooking up the nextKeyView outlet or letting the 
window calculate the key view loop.

--Graham


___

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

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

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

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


Re: Connecting Outlet on Derived Array Controller

2010-03-01 Thread Joanna Carter
Hi Quincey

> With Objective-C 2.0, I can't think of any reason to stick with an informal 
> protocol. Formal protocols mean actual compile-time checking, and they rarely 
> blow up in your face any more.

OK, so forget about informal protocols, otherwise known as categories without 
implementations?

Instead use formal protocols, which can have optional methods.

I think I'm getting the hang of this stuff - it's just the terminology...

Many thanks

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: NSWindow - makeKeyAndOrderFront problem

2010-03-01 Thread Andy Lee
On Mar 1, 2010, at 6:27 PM, Matthew Lindfield Seager wrote:
> On Monday, March 1, 2010, Andreas Mayer  wrote:
>> Try dragging something onto the iTunes source list. iTunes will import it, 
>> but will not activate itself.
> 
> Apples & Oranges... iTunes is (was?) a library application more than a
> player. It also has origins in audio, not video. Then again I think
> the "correct" behaviour is dictated by the principle of least
> surprise...
> 
> If I've told a video player to start playing files on open I would
> generally expect the player to bring itself to the front after
> specifically dropping a media file onto it.

I was going to make a similar comment, but noticed that if I drop a file into 
the iTunes source list (note this is the action Andreas described), it plays 
but iTunes does not come forward.  Also, if I drag a link from Mail into a 
Safari window, the window loads the URL but Safari does not come forward.

If I drag into the application's *icon* in the Dock, the application does come 
forward as I expected.  So there seems to be a distinction between dragging 
into an application's window as opposed to its icon.

If I feel my app should come forward in both cases I do think it should be okay 
to implement it that way, but there *is* precedent for not activating the app.

--Andy

___

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

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

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

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


Forcing the package bit

2010-03-01 Thread Graham Cox
I need to write a package file that is not listed as one of my document types. 
How do I ensure that this will be seen as a package in the Finder? It looks to 
me as though some new flags were added to NSURL to cover this but the code 
needs to work on 10.5 or later.

--Graham


___

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

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

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

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


Re: Forcing the package bit

2010-03-01 Thread Steven Degutis
I believe this can be accomplished by exporting a new UTI that describes
your package type (probably by extending com.apple.package or something like
that). This would be done inside your app's Info.plist file.

-Steven

On Mon, Mar 1, 2010 at 8:14 PM, Graham Cox  wrote:

> I need to write a package file that is not listed as one of my document
> types. How do I ensure that this will be seen as a package in the Finder? It
> looks to me as though some new flags were added to NSURL to cover this but
> the code needs to work on 10.5 or later.
>
> --Graham
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com
>
> This email sent to steven.degu...@gmail.com
>



-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.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: Forcing the package bit

2010-03-01 Thread Neil Allain

On Mar 1, 2010, at 7:14 PM, Graham Cox wrote:

> I need to write a package file that is not listed as one of my document 
> types. How do I ensure that this will be seen as a package in the Finder? It 
> looks to me as though some new flags were added to NSURL to cover this but 
> the code needs to work on 10.5 or later.
> 

This solution works fine:

http://stackoverflow.com/questions/2009687/make-mac-package-bundle-programmatically

I didn't know about the NSURL method, I'll have to check it out.

Neil

___

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

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

Help/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: NSWindow - makeKeyAndOrderFront problem

2010-03-01 Thread Andreas Mayer


Am 02.03.2010 um 00:27 Uhr schrieb Matthew Lindfield Seager:


If I've told a video player to start playing files on open I would
generally expect the player to bring itself to the front after
specifically dropping a media file onto it.


Well, yes. But that's not what we are talking about. We are talking  
about dropping a file onto a *window* of the player application.  
That's not the same thing as dropping it onto the application's icon.


Dragging something onto an application icon - either in the Finder or  
in the Dock - is an explicit request to bring that application to the  
front.


Dragging something inside another application's window is not.

Of course there might be exceptions. There almost always are. :)


or do some usability testing with some target users.


If you do that, please make sure they are actually Mac users, not  
Windows users sitting in front of a Mac. :P



And as this is rather off-topic for cocoa-dev, I'll leave it at that.
I just tried to give some advice. Do what you think is best.


Andreas
___

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

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

Help/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: Private ivars, not marked as IBOutlet, visible in IB

2010-03-01 Thread Shane Stanley
On 2/3/10 3:36 AM, "Joanna Carter"  wrote:

>> That is a legacy of Interface Builder on NextStep, from the days before the
>> IBOutlet marker was added.
> 
> Heheh, I was afraid if that. Surely it's about time, with all the other
> breaking changes for Snow Leopard, that that got broken as well? :-)
> 
>> If you care to try it out, you will find that a method declaration of this
>> form:
>> 
>> - (void)doSomething: (did)sender;
>> 
>> is viewed by Interface Builder as an IBAction method to which you can connect
>> from some control . . .
>> That's also a legacy feature.
> 
> Yup, I'd discovered that one as well but had ignored it as a bad dream ;-)

FWIW, I wouldn't be surprised if both behaviors are what enable
AppleScriptObjC handlers and properties to be used in IB, and perhaps the
same goes for other scripting bridges. So fixing your "bug" might break
several other things rather badly...

-- 
Shane Stanley 
AppleScript Pro, April 2010, Florida 


___

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

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

Help/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: IsReadableFileAtPath

2010-03-01 Thread Charles Srstka
On Mar 1, 2010, at 3:24 PM, Jens Alfke wrote:

> -isReadableFileAtPath is just a convenience. If you don't want to traverse 
> symlinks, call -fileAttributesAtPath:traverseLink: and use NO for the second 
> parameter.

Unfortunately, fileAttributesAtPath:traverseLink: is deprecated. The 
replacement given is attributesOfItemAtPath:error:, which doesn’t traverse 
symlinks. However, the documentation claims that this behavior is not 
guaranteed, and may change in a future version of OS X. Sadly, there does not 
seem to be a non-deprecated replacement for fileAttributesAtPath:traverseLink: 
which has guaranteed behavior.

The best thing to do is probably to use POSIX calls such as lstat().

Charles___

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

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

Help/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: Forcing the package bit

2010-03-01 Thread Graham Cox

On 02/03/2010, at 1:04 PM, Neil Allain wrote:

> 
> On Mar 1, 2010, at 7:14 PM, Graham Cox wrote:
> 
>> I need to write a package file that is not listed as one of my document 
>> types. How do I ensure that this will be seen as a package in the Finder? It 
>> looks to me as though some new flags were added to NSURL to cover this but 
>> the code needs to work on 10.5 or later.
>> 
> 
> This solution works fine:
> 
> http://stackoverflow.com/questions/2009687/make-mac-package-bundle-programmatically
> 
> I didn't know about the NSURL method, I'll have to check it out.
> 
> Neil
> 


Thanks, though it doesn't compile. What the hell is:

union FinderInfoTransmuter finderInfoPointers = { .bytes = 
catInfo.finderInfo };

??

--Graham


___

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

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

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

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


Re: Forcing the package bit

2010-03-01 Thread Graham Cox

On 02/03/2010, at 1:34 PM, Graham Cox wrote:

> Thanks, though it doesn't compile. What the hell is:
> 
>union FinderInfoTransmuter finderInfoPointers = { .bytes = 
> catInfo.finderInfo };


Never mind, I just got rid of it and cast the struct directly:

- (void) setBundleBitOfFile:(NSString*)path toBool:(BOOL)newValue
{
const char* pathFSR = [path fileSystemRepresentation];
FSRef   ref;
OSStatuserr = FSPathMakeRef((const UInt8*)pathFSR, &ref, 
/*isDirectory*/ NULL);

if (err == noErr)
{
struct FSCatalogInfo catInfo;
err = FSGetCatalogInfo(&ref,
   kFSCatInfoFinderInfo,
   &catInfo,
   /*outName*/ NULL,
   /*FSSpec*/ NULL,
   /*parentRef*/ NULL);

if (err == noErr)
{
if (newValue)
((FolderInfo*)&catInfo.finderInfo)->finderFlags |=  kHasBundle;
else
((FolderInfo*)&catInfo.finderInfo)->finderFlags &= ~kHasBundle;

FSSetCatalogInfo(&ref,
 kFSCatInfoFinderInfo,
 &catInfo);
}
}
}

Thanks - it does the job for me.

One small follow-up question though. I'm also trying to set the extension of 
this package file hidden by default, using:


[[NSFileManager defaultManager] setAttributes:[[self class] 
defaultFileAttributes] ofItemAtPath:[self path] error:&error];

Where the default attributes are:

+ (NSDictionary*)   defaultFileAttributes
{
return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber 
numberWithBool:YES], NSFileExtensionHidden, nil];

}


But the extension is not hidden. Opening Get Info in the Finder, the "hide 
extension" checkbox is greyed out, though is is checked, as if the extension 
were hidden.

Any idea what's going on there?

--Graham





___

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

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

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

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


Re: Menu Items

2010-03-01 Thread David Blanton
Ok.  This is all very interesting.  I did have acceptsFirstResponder  
returning YES in the view that contains the action but it was not  
being called.


Then the light bulb went off ... and by clicking in the view,   
acceptsFirstResponder is called and then the validateMenuItem etc etc.


This does make sense in the context of the program as the menu item I  
want to invoke is related to the view.


I'm gettin' it.

Thanks to all!

-db


On Mar 1, 2010, at 5:11 PM, Graham Cox wrote:



On 02/03/2010, at 10:47 AM, David Blanton wrote:

I connected a menu item to an action in First Responder. The action  
is defined in a view.


This, apparently, does not define the Target as I put  
validateMenuItem in the same view as the action but it is not called.


So, how does one define the Target?

The view and the Menu Item are in different nib files.

I really need to get a handle on how the best way to work with menus.



You are doing it right. First Responder defines the target as the  
first responder currently within the app. When that's your view, its  
action and menu validation method will be called; when that's not  
your view, they won't.


So it sounds as if your view is not becoming first responder, rather  
than a problem with the menu itself.


Note that the ability to click a view and have it respond to mouse  
events does not indicate first responder is that view - FR really  
pertains to keyboard input and other context-sensitive UI like  
menus. Your view must return YES to -acceptsFirstResponder:  
(inherited from NSResponder) which is NO by default. You'll probably  
also want to set up how that view fits in with other potential  
responders which involves hooking up the nextKeyView outlet or  
letting the window calculate the key view loop.


--Graham







___

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

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

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

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


Interface Builder plugin for NSWindow subclass?

2010-03-01 Thread Murat Konar
Is it possible to create an Interface Builder plugin for NSWindow (or  
NSPanel) subclasses?


In NSWindow's docs it says "Although the NSWindow class inherits the  
NSCoding protocol from NSResponder, the class does not support coding.  
[...] Any attempt to archive or unarchive an NSWindow object using a  
keyed coding object raises an NSInvalidArgumentException exception."


Since instantiating custom subclasses in IB depends on archiving and  
unarchiving of objects, it would seem from the above that you can't  
make an IB plugin for subclasses of NSWindow.


Really?

_murat
___

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

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

Help/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: Menu Items

2010-03-01 Thread Graham Cox

On 02/03/2010, at 2:07 PM, David Blanton wrote:

> Then the light bulb went off ... and by clicking in the view,  
> acceptsFirstResponder is called and then the validateMenuItem etc etc.


Also, if you want the view to be first responder by default when the window is 
activated, hook up the window's initialFirstResponder outlet to the view.

--Graham___

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

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

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

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


Re: NSForegroundColorAttributeName without AppKit

2010-03-01 Thread BareFeet
Thanks Graham for your reply:

>> I have some working code for adding attributes to a string. I'd like to 
>> modify it so it will work without needing AppKit. I can get it all going 
>> except the NSForegroundColorAttributeName constant which seems to only exist 
>> in AppKit.
> 
> If you log the actual value of that constant, it's simply @"NSColor".

Unfortunately it seems that using the @"NSColor" key as part of an 
NSAttributedString also requires AppKit. Put another way, I can't see any way 
to draw multi-colored text in a wrapping text field without using AppKit.

Thanks,
Tom
BareFeet

___

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

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

Help/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: Forcing the package bit

2010-03-01 Thread Ken Thomases
On Mar 1, 2010, at 9:06 PM, Graham Cox wrote:

> [[NSFileManager defaultManager] setAttributes:[[self class] 
> defaultFileAttributes] ofItemAtPath:[self path] error:&error];
> 
> Where the default attributes are:
> 
> + (NSDictionary*) defaultFileAttributes
> {
>   return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber 
> numberWithBool:YES], NSFileExtensionHidden, nil];
> }
> 
> But the extension is not hidden. Opening Get Info in the Finder, the "hide 
> extension" checkbox is greyed out, though is is checked, as if the extension 
> were hidden.
> 
> Any idea what's going on there?

No, but you might try LSSetExtensionHiddenForURL(), instead.

Cheers,
Ken

___

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

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

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

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


Re: NSForegroundColorAttributeName without AppKit

2010-03-01 Thread Steven Degutis
NSAttributedString is part of Foundation.framework and so are all NSStrings
(including literal constants like @"NSColor"). Thus, you can use that safely
without linking against AppKit.framework; however, I advise against using
string literals in place of Apple's constants, since they might change under
your nose.

-Steven

On Mon, Mar 1, 2010 at 10:27 PM, BareFeet wrote:

> Thanks Graham for your reply:
>
> >> I have some working code for adding attributes to a string. I'd like to
> modify it so it will work without needing AppKit. I can get it all going
> except the NSForegroundColorAttributeName constant which seems to only exist
> in AppKit.
> >
> > If you log the actual value of that constant, it's simply @"NSColor".
>
> Unfortunately it seems that using the @"NSColor" key as part of an
> NSAttributedString also requires AppKit. Put another way, I can't see any
> way to draw multi-colored text in a wrapping text field without using
> AppKit.
>
> Thanks,
> Tom
> BareFeet
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com
>
> This email sent to steven.degu...@gmail.com
>



-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.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: Forcing the package bit

2010-03-01 Thread Sean McBride
Graham Cox (graham@bigpond.com) on 2010-03-02 20:14 said:

>I need to write a package file that is not listed as one of my document
>types. How do I ensure that this will be seen as a package in the
>Finder? It looks to me as though some new flags were added to NSURL to
>cover this but the code needs to work on 10.5 or later.

If you use the MoreFilesX sample code, you can just do this:

 FSChangeFinderFlags (&bundleFSRef, true, kHasBundle);

(It's always a good idea to set the bundle bit on all bundle-type
documents because if your application is not on any of your disks, the
Finder will show a folder. Ever install a fresh system (with no Xcode)
and navigate to a folder with an .xcodeproj?  It will appear as a folder
because Xcode doesn't set the bundle bit.)

Sean


___

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

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

Help/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: NSWindow - makeKeyAndOrderFront problem

2010-03-01 Thread Alexander Bokovikov

Hi, All,

I'm sorry for an offtopic, so I'm writing just to close the thread.

On 02.03.2010, at 7:37, Andy Lee wrote:

If I feel my app should come forward in both cases I do think it  
should be okay to implement it that way, but there *is* precedent  
for not activating the app.


I'd even say, there were no precedents (I could not find them at  
least) of doing anything else. Though I can't explain it for myself...


On 02.03.2010, at 7:37, Matthew Lindfield Seager wrote:


For more "guidance" see what other popular or Apple apps do (e.g.
QuickTime Player, etc) or do some usability testing with some target
users.


On 02.03.2010, at 7:37, Andreas Mayer wrote:


Dragging something onto an application icon - either in the Finder or
in the Dock - is an explicit request to bring that application to the
front.

Dragging something inside another application's window is not.


As for "something", I could agree, moreover, I'd hate it if iTunes  
would activate itself each time I drop a link into the playlist. But  
as for my case, when we can expect nothing but the only result - a  
playback beginning, it looks as surprise for me, when ALL video  
players, I saw, behave in the same "silent" manner -- they do not  
activate themself.



or do some usability testing with some target users.


If you do that, please make sure they are actually Mac users, not
Windows users sitting in front of a Mac. :P


Perhaps I'm still a Windows user :(


And as this is rather off-topic for cocoa-dev, I'll leave it at that.
I just tried to give some advice. Do what you think is best.


It looks like the best modus operandi here is:

"Lord, grant me the serenity to accept the things I cannot change"

Thanks to all who answered!

Best regards,
Alex

___

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

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

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

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


Re: NSForegroundColorAttributeName without AppKit

2010-03-01 Thread Murat Konar


On Mar 1, 2010, at 7:27 PM, BareFeet wrote:

Unfortunately it seems that using the @"NSColor" key as part of an  
NSAttributedString also requires AppKit.


Well, that's because NSColor (the class) is part of AppKit.

_murat
___

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

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

Help/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: Menu Items

2010-03-01 Thread David Blanton
Cool .. ."hook up the window's initialFirstResponder outlet to the  
view" is the last piece for me.


Thanks a bunch Graham!

- db

On Mar 1, 2010, at 8:12 PM, Graham Cox wrote:



On 02/03/2010, at 2:07 PM, David Blanton wrote:

Then the light bulb went off ... and by clicking in the view,   
acceptsFirstResponder is called and then the validateMenuItem etc  
etc.



Also, if you want the view to be first responder by default when the  
window is activated, hook up the window's initialFirstResponder  
outlet to the view.


--Graham




___

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

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

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

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


Re: NSForegroundColorAttributeName without AppKit

2010-03-01 Thread Ken Thomases
On Mar 1, 2010, at 9:27 PM, BareFeet wrote:

>>> I have some working code for adding attributes to a string. I'd like to 
>>> modify it so it will work without needing AppKit. I can get it all going 
>>> except the NSForegroundColorAttributeName constant which seems to only 
>>> exist in AppKit.
>> 
>> If you log the actual value of that constant, it's simply @"NSColor".
> 
> Unfortunately it seems that using the @"NSColor" key as part of an 
> NSAttributedString also requires AppKit. Put another way, I can't see any way 
> to draw multi-colored text in a wrapping text field without using AppKit.

Huh?  How do you hope to draw any kind of text in a text field without using 
AppKit?

And you certainly can add the attribute to the attributed string without AppKit.

Regards,
Ken

___

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

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

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

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


Re: NSForegroundColorAttributeName without AppKit

2010-03-01 Thread Sean McBride
BareFeet (list.develo...@tandb.com.au) on 2010-03-02 22:27 said:

>>> I have some working code for adding attributes to a string. I'd like
>to modify it so it will work without needing AppKit. I can get it all
>going except the NSForegroundColorAttributeName constant which seems to
>only exist in AppKit.
>>
>> If you log the actual value of that constant, it's simply @"NSColor".
>
>Unfortunately it seems that using the @"NSColor" key as part of an
>NSAttributedString also requires AppKit. Put another way, I can't see
>any way to draw multi-colored text in a wrapping text field without
>using AppKit.

Well, NSColor itself is part of AppKit, so I'm not sure you'll be able
to do much colour-related stuff without AppKit.

Sean


___

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

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

Help/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   >