Re: My try/catch block isn't catching exceptions on 10.6

2009-11-30 Thread Kai Brüning

On 28.11.2009, at 13:57, Gwynne Raskind wrote:

 On Nov 28, 2009, at 4:25 AM, Greg Parker wrote:
 Here's a fun idiom for handling both C++ and Objective-C exceptions in the 
 same place (on iPhone and 64-bit Mac).
 
   @try {
   // do stuff
   } @catch (NSException *e) {
   // NSException
   } @catch (id e) {
   // Other Objective-C exception
   } @catch (...) {
   // Non-ObjC exception
   // Decode it by rethrowing it inside a C++ try/catch.
   try {
   @throw;
   } catch (std::bad_cast e) {
   // C++ failed dynamic cast to reference type
   } catch (...) {
   // Other C++ exception
   // or non-ObjC non-C++ foreign exception
   }
   }
 
 
 I apologize if this is a dense question, but can't you just go like this?
 
   @try {
   // do stuff
   } @catch (NSException *e) {
   // NSException
   } @catch (id e) {
   // Other Objective-C exception
   } @catch (std::bad_cast e) {
   // C++ failed dynamic cast to reference type
   } @catch (...) {
   // Other C++ exception
   // or non-ObjC non-C++ foreign exception
   }

No - there’s a syntactically subtle but important difference above between 
@try/@catch and try/catch, the further being the Objective-C variant, the later 
C++.

Kai

___

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

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

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

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


Re: troubles with tableview

2009-11-30 Thread Graham Cox

On 30/11/2009, at 7:21 PM, Dorimedont Bancescu wrote:

 -why in initWithCoder the array is loaded, has all the elements and when 
 numberOfRowsInTableView message is send the array is empty and has a 
 different memory address?


Probably because you have two distinct objects. Check the address of 'self' in 
the case of -init and -initWithCoder:

-initWithCoder: is, as its name suggests, an init method, which is invoked on a 
freshly alloc'ed object. It is not invoked on an existing object to provide it 
with new content. I think your problem probably lies in the code above this 
that is causing the -initWithCoder: method to be invoked by dearchiving 
something. When you do that you get a new object, but the table's datasource is 
still set to the previous one.

I'm cc'ing this back to the list in case anyone else can put their finger on 
it, but from what you've posted so far that's my best guess.

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


NSWorkspace in a daemon

2009-11-30 Thread Nyxouf da ouf
Hi,

I have an Obj-c program who run as a daemon, using launchd, and that look
for NSWorkspaceDidMountNotification.

*[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(diskDidMount:) name:NSWorkspaceDidMountNotification
object:nil];*
-(void)diskDidMount:(NSNotification*)notif
{
 NSLog(@disk did mount);
}

My problem is that when the daemon is launched as root the notification
isn't catched, how can I solve this ?

Thanks.

Nyxem.
___

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

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

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

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


Re: Apache Module

2009-11-30 Thread Sherm Pendley
On Sat, Nov 28, 2009 at 1:19 PM, Mr. Gecko grmrge...@gmail.com wrote:
 Ok, I know your idea of a CGI Proxy like PHP CGI

That's not what I said. Did you read the link I gave you?

 On Nov 28, 2009, at 9:32 AM, Sherm Pendley wrote:

 Keep in mind though, that I posted that nearly five years ago, and
 wrote the code for Apache 1.x. The basic idea of registering a
 trampoline function that bounces requests to your handler class still
 works, but you'll need to update the code to the Apache 2.x API.

I'm not talking about a CGI Proxy here. Apache's module API doesn't
know how to directly call an Objective-C method. So, you need to write
a C function that bounces the call to your method. Such functions
are commonly called trampoline functions.

sherm--

-- 
Cocoa programming in Perl:
http://www.camelbones.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


Hiding String Constant in Compiled Code

2009-11-30 Thread Richard Somers
Consider a string constant, @string, in source code that also  
appears in the compiled unix executable file. If someone knew the  
value of the string they could easily open the executable with  
TextEdit, find the string, replace it with a perfectly functioning one  
of their own making, and then save the file and the application would  
run with the new string value.


Is there some way to easily hide or munge a string constant so that it  
does not appear in the compiled executable?


--Richard

___

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

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

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

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


Re: NSWorkspace in a daemon

2009-11-30 Thread Bill Garrison


On Nov 30, 2009, at 9:17 AM, Nyxouf da ouf wrote:


Hi,

I have an Obj-c program who run as a daemon, using launchd, and that  
look

for NSWorkspaceDidMountNotification.

*[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
selector:@selector(diskDidMount:) name:NSWorkspaceDidMountNotification
object:nil];*
-(void)diskDidMount:(NSNotification*)notif
{
NSLog(@disk did mount);
}

My problem is that when the daemon is launched as root the  
notification

isn't catched, how can I solve this ?


This probably has something to do with Mach namespaces.

http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECMACHBOOTSTRAPBASICS 



The daemon launched as root gets its own Mach namespace, separate from  
other user-level processes on the box.  The  
NSWorkspaceDidMountNotification probably won't cross the Mach  
namespace boundary between the root-based daemon and other user-level  
apps that might be listening for it.


Bill
___

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

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

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

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


Re: NSWorkspace in a daemon

2009-11-30 Thread Nyxem
I found something that said to use NSApplicationLoad() and it seems to work.

Nyxem.


On Nov 30, 2009, at 4:25 PM, Bill Garrison wrote:

 
 On Nov 30, 2009, at 9:17 AM, Nyxouf da ouf wrote:
 
 Hi,
 
 I have an Obj-c program who run as a daemon, using launchd, and that look
 for NSWorkspaceDidMountNotification.
 
 *[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
 selector:@selector(diskDidMount:) name:NSWorkspaceDidMountNotification
 object:nil];*
 -(void)diskDidMount:(NSNotification*)notif
 {
 NSLog(@disk did mount);
 }
 
 My problem is that when the daemon is launched as root the notification
 isn't catched, how can I solve this ?
 
 This probably has something to do with Mach namespaces.
 
 http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECMACHBOOTSTRAPBASICS
 
 The daemon launched as root gets its own Mach namespace, separate from other 
 user-level processes on the box.  The NSWorkspaceDidMountNotification 
 probably won't cross the Mach namespace boundary between the root-based 
 daemon and other user-level apps that might be listening for it.
 
 Bill
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/nyx0uf%40gmail.com
 
 This email sent to nyx...@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: NSWorkspace in a daemon

2009-11-30 Thread Dave DeLong
While it may solve your problem, that's probably not a good idea.  
NSApplicationLoad() loads the AppKit framework and its dependencies (like Input 
Managers), which (when running as root) introduce a mess of security 
vulnerabilities into your program (attackers can use your app to gain root 
access, etc).

Dave

On Nov 30, 2009, at 8:31 AM, Nyxem wrote:

 I found something that said to use NSApplicationLoad() and it seems to work.
 
 Nyxem.


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: NSWorkspace in a daemon

2009-11-30 Thread Jean-Daniel Dupas

Le 30 nov. 2009 à 16:25, Bill Garrison a écrit :

 
 On Nov 30, 2009, at 9:17 AM, Nyxouf da ouf wrote:
 
 Hi,
 
 I have an Obj-c program who run as a daemon, using launchd, and that look
 for NSWorkspaceDidMountNotification.
 
 *[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
 selector:@selector(diskDidMount:) name:NSWorkspaceDidMountNotification
 object:nil];*
 -(void)diskDidMount:(NSNotification*)notif
 {
 NSLog(@disk did mount);
 }
 
 My problem is that when the daemon is launched as root the notification
 isn't catched, how can I solve this ?
 
 This probably has something to do with Mach namespaces.
 
 http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECMACHBOOTSTRAPBASICS
 
 The daemon launched as root gets its own Mach namespace, separate from other 
 user-level processes on the box.  The NSWorkspaceDidMountNotification 
 probably won't cross the Mach namespace boundary between the root-based 
 daemon and other user-level apps that might be listening for it.
 
 Bill

AppKit is not daemon safe.

http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECLIVINGDANGEROUSLY


-- 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: NSWorkspace in a daemon

2009-11-30 Thread Nyxem
So what is the right way to do this ?

Nyxem.

On Nov 30, 2009, at 4:37 PM, Jean-Daniel Dupas wrote:

 
 Le 30 nov. 2009 à 16:25, Bill Garrison a écrit :
 
 
 On Nov 30, 2009, at 9:17 AM, Nyxouf da ouf wrote:
 
 Hi,
 
 I have an Obj-c program who run as a daemon, using launchd, and that look
 for NSWorkspaceDidMountNotification.
 
 *[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
 selector:@selector(diskDidMount:) name:NSWorkspaceDidMountNotification
 object:nil];*
 -(void)diskDidMount:(NSNotification*)notif
 {
 NSLog(@disk did mount);
 }
 
 My problem is that when the daemon is launched as root the notification
 isn't catched, how can I solve this ?
 
 This probably has something to do with Mach namespaces.
 
 http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECMACHBOOTSTRAPBASICS
 
 The daemon launched as root gets its own Mach namespace, separate from other 
 user-level processes on the box.  The NSWorkspaceDidMountNotification 
 probably won't cross the Mach namespace boundary between the root-based 
 daemon and other user-level apps that might be listening for it.
 
 Bill
 
 AppKit is not daemon safe.
 
 http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECLIVINGDANGEROUSLY
 
 
 -- 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/nyx0uf%40gmail.com
 
 This email sent to nyx...@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


AudioToolbox Pitch Bend?

2009-11-30 Thread Chunk 1978
is it possible to bend the pitch of a sound using AudioToolbox?  how
can i accomplish a pitch bend of a live running sound?
___

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

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

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

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


Re: Apache Module

2009-11-30 Thread Jens Alfke

On Nov 30, 2009, at 8:48 AM, Mr. Gecko wrote:

 I decided to write it like PHP CGI, it's working fine for me, and I'm able to 
 get all the information I need from the server by NSFileHandle and 
 NSProcessInfo.

Cool. If you find that performance is a problem, you should look into using 
SCGI. This will allow your process to keep running and handle multiple requests 
(one at a time) instead of being quit and re-launched for each request. SCGI is 
pretty easy to implement — you basically just run a loop that reads the request 
headers and info from stdin, handles the request and writes back to stdout, 
then goes back and waits for another request. (I wrote an implementation a few 
years ago but I don't have access to the source anymore.)

—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: AudioToolbox Pitch Bend?

2009-11-30 Thread Jens Alfke

On Nov 30, 2009, at 9:04 AM, Chunk 1978 wrote:

 is it possible to bend the pitch of a sound using AudioToolbox?  

Nope. For that you need to use AudioUnits; there's a built-in unit that will do 
time/pitch shifting.

 how can i accomplish a pitch bend of a live running sound?

Basically you'd create an AUGraph that looks like
audio-in --- pitch-shifter --- audio-out

CoreAudio is kind of involved :( but there's a bunch of C++ sample code and 
utilities in /Developer/Examples/CoreAudio/. If you run into trouble, the 
coreaudio-api list is the right place to ask questions.

—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: Hiding String Constant in Compiled Code

2009-11-30 Thread Matt Neuburg
On Mon, 30 Nov 2009 07:48:42 -0700, Richard Somers
rsomers.li...@infowest.com said:
Consider a string constant, @string, in source code that also
appears in the compiled unix executable file. If someone knew the
value of the string they could easily open the executable with
TextEdit, find the string, replace it with a perfectly functioning one
of their own making, and then save the file and the application would
run with the new string value.

If the app is code-signed, it will not run when the executable is altered.
m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
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: AudioToolbox Pitch Bend?

2009-11-30 Thread Chunk 1978
thanks.  i'm going to check out apple's iPhoneMultichannelMixerText
sample code.  i assume the sample code shows how to change volume for
each track (audio-in / volume / audio-out), so i'm hoping replacing
volume for a pitch shift won't be too difficult..

On Mon, Nov 30, 2009 at 12:14 PM, Jens Alfke j...@mooseyard.com wrote:

 On Nov 30, 2009, at 9:04 AM, Chunk 1978 wrote:

 is it possible to bend the pitch of a sound using AudioToolbox?

 Nope. For that you need to use AudioUnits; there's a built-in unit that will 
 do time/pitch shifting.

 how can i accomplish a pitch bend of a live running sound?

 Basically you'd create an AUGraph that looks like
        audio-in --- pitch-shifter --- audio-out

 CoreAudio is kind of involved :( but there's a bunch of C++ sample code and 
 utilities in /Developer/Examples/CoreAudio/. If you run into trouble, the 
 coreaudio-api list is the right place to ask questions.

 —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: Hiding String Constant in Compiled Code

2009-11-30 Thread Jens Alfke

On Nov 30, 2009, at 9:23 AM, Matt Neuburg wrote:

 If the app is code-signed, it will not run when the executable is altered.

In which case, the hacker just needs to strip the signature.
If your code checks for a signature, the hacker can re-sign it with his own.
If your code checks for your key in the signature, the hacker can replace the 
public key you're checking against with his own.
etc...

We had this thread a few months ago … the take-away is that checking the 
signature of already-running code is not a viable security technique. Checking 
has to be done before you load the code.

Locks are just to keep honest people out.

—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: Hiding String Constant in Compiled Code

2009-11-30 Thread Richard Somers

On Nov 30, 2009, at 10:23 AM, Matt Neuburg wrote:

If the app is code-signed, it will not run when the executable is  
altered.



I could be wrong but I do not think this is the case. The  
documentation states Once you have signed your code, any change in  
the code that you did not intend—whether introduced accidently or by  
hackers—can be detected by the system. No where does it say the  
system will not run the altered code.


--Richard

___

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

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

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

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


removing all sublayers from a layer with fast enumeration

2009-11-30 Thread Matt Neuburg
To remove all sublayers from a layer, it is sufficient to set that layer's
sublayers property to nil, so this code is completely unnecessary. But I'm
just curious as to why it doesn't work:

for (CALayer* sub in myview.layer.sublayers)
  [sub removeFromSuperlayer];

This crashes as if the fast enumeration itself were somehow illegal. Why?
Thx -

m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
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


How duplicate the text color of Apple's labels in UITableView cells

2009-11-30 Thread Steve Fogel
Hi, all...

In various places in my app, I'd like to create labels that have the same 
color, weight, and font size as the labels in default UITableView cells. For 
example, I'd like to duplicate the appearance, especially the color, of the 
textLabel and the detailTextLabel of the table cell with the style 
UITableViewVellStyleValue2.

Does anyone have the correct UIColor to do this? Would you be willing to share 
it please?

Thanks!

Steve Fogel
Crescent Computing___

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

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

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

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


Does NSData rearrange the order of bits?

2009-11-30 Thread Brad Gibbs
Hi,

I'm doing bit-packing via a C function.  Logging the bits of the C function 
shows the expected result.  If I create a string with a hex value format, I get 
the correct hex string, but, if I try to put the bytes into an NSData object 
with [NSData dataWithBytes: length], the order of the bits changes.  All of the 
right elements are there, but they're in the wrong order (target data should be 
f651, as shown in the Target string is ... log).

My code:


// get the target int from the text field
unsigned int tgtValue = [self.tgtTF intValue];

// use the target int and type to pack the bits into an int
uint32_t tgtBinary = setAnalogValueForIndex(cid, tgtValue);
NSString *tgtString = [NSString stringWithFormat:@%x, tgtBinary];
NSData *tgtData = [NSData dataWithBytes: tgtBinary length: 
sizeof(tgtBinary)];
NSLog(@Target data is %...@.  Target string is %@, tgtData, 
tgtString);


The logs:

011001010001
2009-11-30 11:02:26.126 CertTest[11959:a0f] Target data is 510600f0.  Target 
string is f651
2009-11-30 11:02:26.204 CertTest[11959:a0f] After adding target, cmdData is 
510600f0

If NSData is rearranging the bits, is there some way to prevent this?


Thanks.

Brad
___

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

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

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

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


Re: removing all sublayers from a layer with fast enumeration

2009-11-30 Thread David Duncan

Your modifying an array that is being enumerated, which is illegal.

--
David Duncan @ My iPhone

On Nov 30, 2009, at 2:23 PM, Matt Neuburg m...@tidbits.com wrote:

To remove all sublayers from a layer, it is sufficient to set that  
layer's
sublayers property to nil, so this code is completely unnecessary.  
But I'm

just curious as to why it doesn't work:

for (CALayer* sub in myview.layer.sublayers)
 [sub removeFromSuperlayer];

This crashes as if the fast enumeration itself were somehow illegal.  
Why?

Thx -

m.

--
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
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/david.duncan%40apple.com

This email sent to david.dun...@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: removing all sublayers from a layer with fast enumeration

2009-11-30 Thread Nick Zitzmann

On Nov 30, 2009, at 12:23 PM, Matt Neuburg wrote:

 To remove all sublayers from a layer, it is sufficient to set that layer's
 sublayers property to nil, so this code is completely unnecessary. But I'm
 just curious as to why it doesn't work:
 
 for (CALayer* sub in myview.layer.sublayers)
  [sub removeFromSuperlayer];
 
 This crashes as if the fast enumeration itself were somehow illegal. Why?

What happens if you try enumerating on a copy of the sublayer array? That's 
what I usually do in this situation...

Nick Zitzmann
http://www.chronosnet.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: removing all sublayers from a layer with fast enumeration

2009-11-30 Thread Matt Neuburg
On or about 11/30/09 11:33 AM, thus spake David Duncan
david.dun...@apple.com:

 Your modifying an array that is being enumerated, which is illegal.

I thought of that, of course, but I doubted that could be the reason,
because I changed the code to look like this:

NSArray* arr = [NSArray arrayWithArray: myview.layer.sublayers];
for (CALayer* sub in arr)
   [sub removeFromSuperlayer];

and I still got the same crash. Enumerating thru arr with objectAtIndex:
causes no problem; it's the fast enumeration that's troublesome. m.

 On Nov 30, 2009, at 2:23 PM, Matt Neuburg m...@tidbits.com wrote:
 
 To remove all sublayers from a layer, it is sufficient to set that
 layer's
 sublayers property to nil, so this code is completely unnecessary.
 But I'm
 just curious as to why it doesn't work:
 
 for (CALayer* sub in myview.layer.sublayers)
  [sub removeFromSuperlayer];
 
 This crashes as if the fast enumeration itself were somehow illegal.
 Why?
 Thx -

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring  Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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: removing all sublayers from a layer with fast enumeration

2009-11-30 Thread Dave Keck
Is the crash due to an exception? Is anything printed to stdout?

I'll go out on a limb and say your view is layer-backed instead of
layer-hosted... ?
___

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

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

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

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


Behavior of CFStringUpper/Lowercase for NULL Locale?

2009-11-30 Thread Jim Correia
The documentation for CFStringUppercase says:

locale

A CFLocale object that specifies a particular language or
region. Prior to Mac OS X v10.3, this parameter was an untyped
pointer and not used.

The locale argument affects the case mapping algorithm. For
example, for the Turkish locale, case-insensitive compare
matches “I” to “ı” (Unicode code point U+0131, Latin Small
Dotless I), not the normal “i” character.


Prior to 10.3, the parameter was unused and NULL was always passed.

The documentation doesn’t specify what the case mapping behavior is if NULL is 
passed for a locale. What is the behavior in that case? (Current locale? System 
locale?)

- Jim___

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

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

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

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


Re: Does NSData rearrange the order of bits?

2009-11-30 Thread Jens Alfke

On Nov 30, 2009, at 11:27 AM, Brad Gibbs wrote:

 I'm doing bit-packing via a C function.  Logging the bits of the C function 
 shows the expected result.  If I create a string with a hex value format, I 
 get the correct hex string, but, if I try to put the bytes into an NSData 
 object with [NSData dataWithBytes: length], the order of the bits changes.  
 All of the right elements are there, but they're in the wrong order (target 
 data should be f651, as shown in the Target string is ... log).
...
 2009-11-30 11:02:26.126 CertTest[11959:a0f] Target data is 510600f0.  
 Target string is f651

Isn't this the expected byte ordering for a little-endian CPU like x86? The 
least-significant byte of an integer appears first.

—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: Does NSData rearrange the order of bits?

2009-11-30 Thread Brad Gibbs
I guess it is.  I had another issue that was preventing the code from working 
properly.  Another list member mailed me an explanation offline, causing me to 
look for and find the real problem preventing my code from running.  

Thanks for the response.


On Nov 30, 2009, at 12:22 PM, Jens Alfke wrote:

 
 On Nov 30, 2009, at 11:27 AM, Brad Gibbs wrote:
 
 I'm doing bit-packing via a C function.  Logging the bits of the C function 
 shows the expected result.  If I create a string with a hex value format, I 
 get the correct hex string, but, if I try to put the bytes into an NSData 
 object with [NSData dataWithBytes: length], the order of the bits changes.  
 All of the right elements are there, but they're in the wrong order (target 
 data should be f651, as shown in the Target string is ... log).
 ...
 2009-11-30 11:02:26.126 CertTest[11959:a0f] Target data is 510600f0.  
 Target string is f651
 
 Isn't this the expected byte ordering for a little-endian CPU like x86? The 
 least-significant byte of an integer appears first.
 
 —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: Does NSData rearrange the order of bits?

2009-11-30 Thread Peter Duniho

On Nov 30, 2009, at 11:27 AM, Brad Gibbs wrote:


Hi,

I'm doing bit-packing via a C function.  Logging the bits of the C  
function shows the expected result.  If I create a string with a hex  
value format, I get the correct hex string, but, if I try to put the  
bytes into an NSData object with [NSData dataWithBytes: length], the  
order of the bits changes.  All of the right elements are there, but  
they're in the wrong order (target data should be f651, as shown  
in the Target string is ... log).


The output looks correct to me.  In particular:


[...]
  NSString *tgtString = [NSString stringWithFormat:@%x, tgtBinary];


Here (above), you ask NSString to interpret the bytes passed as a  
single integer value as exactly that: an integer value, formatted as  
hexadecimal.


	NSData *tgtData = [NSData dataWithBytes: tgtBinary length:  
sizeof(tgtBinary)];


But here (above), you as NSData to interpret the bytes passed as a  
sequence of bytes, in the order in which they appear in memory.


Presumably you are executing this code on an Intel Mac, where the byte  
ordering is little-endian.  This means the least-significant byte  
appears first in memory order.  So, that's the order you see when you  
get NSData to produce a string of the bytes it contains.



[...]
If NSData is rearranging the bits, is there some way to prevent this?


To me, a more interesting question is: do you really need some way to  
prevent this?  What exactly are you doing with the NSData later, and  
why is it important to you that the byte order be some specific  
endianness?


If you really need control over endianness, you can use the Core  
Endian API (http://developer.apple.com/mac/library/documentation/Carbon/Reference/CoreEndianReference/ 
) to always make sure the bytes are of some particular endianness  
regardless of the computer's native format.  But it may be that the  
endianness doesn't matter.  You should be sure you know the  
difference, and what applies to your own code.


Pete
___

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

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

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

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


iterating and removing objects from a collection

2009-11-30 Thread Dennis Munsie
On a related, yet different note...

I run into this all the time where I need to iterate through an
NSMutableArray (or set, etc, etc) and remove some of the items.  My normal
pattern has been this:

NSMutableSet *removeSet = [[NSMutableSet alloc] init];
for(NSObject *foo in myArray) {
   if(needToRemoveFoo) {
  [removeSet addObject:foo];
   }
}
for(NSObject *foo in removeSet) {
   [myArray removeObject:foo];
}
[removeSet release];


If I have to do multiple passes at the objects in myArray, I'll sometimes do
[removeSet removeAllObjects] instead of [removeSet release] and reuse the
NSMutableSet object as necessary.

Would it be better in general to make a copy of myArray in this case and
remove the objects directly from myArray as I iterate over the copy?  Or are
the two methods generally equal in terms of performance and memory usage?

I am currently doing this on the iPhone, so I am concerned with my memory
and CPU usage more than I would be on the Mac.  I also happen to be doing
this once every 30th or 60th of a second as part of my update loop in a
game.

Thanks!

On Mon, Nov 30, 2009 at 2:36 PM, Nick Zitzmann n...@chronosnet.com wrote:

 What happens if you try enumerating on a copy of the sublayer array? That's
 what I usually do in this situation...


-- 
dennis
___

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

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

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

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


Re: Keyword @defs

2009-11-30 Thread Dennis Munsie
Not that I'm advocating it, but you can also declare a field as @public to
allow you to access it via the - operator.  Of course, I could be missing
some compiler magic going on behind the scene as well, and it may not
actually be the same speed wise as @defs was.

Not to mention that it's just plain nasty :)

dennis

On Sun, Nov 29, 2009 at 8:54 PM, Bill Bumgarner b...@mac.com wrote:


 On Nov 29, 2009, at 4:21 PM, Oftenwrong Soong wrote:

  What exactly is this @defs keyword supposed to do?

 It effectively turned an Objective-C class declaration into a standard C
 structure such that you could access the instance variables directly via a
 simple - operator.   Was mostly used for speed of access when working with
 poorly architected classes. ;)

 It has been deprecated in 32 bit and removed entirely in the modern ABI [64
 bit and iPhone OS] because it, obviously, totally and completely destroys
 encapsulation.  It also makes it impossible to implement non-fragile iVars.

 b.bum

 ___

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

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

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

 This email sent to dmun...@gmail.com




-- 
dennis
___

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

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

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

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


Re: Keyword @defs

2009-11-30 Thread Bill Bumgarner

On Nov 30, 2009, at 12:50 PM, Dennis Munsie wrote:

 Not that I'm advocating it, but you can also declare a field as @public to 
 allow you to access it via the - operator.  Of course, I could be missing 
 some compiler magic going on behind the scene as well, and it may not 
 actually be the same speed wise as @defs was.

The compiler preserves the non-fragile part of non-fragile ivars when using 
the - operator. 

 Not to mention that it's just plain nasty :)

Yup, that it is.

b.bum

___

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

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

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

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


Re: Core Data - any way to back it with something other than SQLite 3?

2009-11-30 Thread Barry Wark
You might take a look at the BaseTen framework
(http://basetenframework.org/). It claims to be a Core Data-like API
on top of PostgreSQL. I haven't used it myself but have been following
the project.

On Thu, Nov 26, 2009 at 6:53 PM, William Squires wsqui...@satx.rr.com wrote:
 Hi all!
  Is there a way to back a Core Data model with a relational DB other than
 SQLite 3? For example, PostGREs, or MySQL?

 ___

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

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

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

 This email sent to barryw...@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: iterating and removing objects from a collection

2009-11-30 Thread Ken Thomases
On Nov 30, 2009, at 2:45 PM, Dennis Munsie wrote:

 I run into this all the time where I need to iterate through an
 NSMutableArray (or set, etc, etc) and remove some of the items.  My normal
 pattern has been this:
 
 NSMutableSet *removeSet = [[NSMutableSet alloc] init];
 for(NSObject *foo in myArray) {
   if(needToRemoveFoo) {
  [removeSet addObject:foo];
   }
 }
 for(NSObject *foo in removeSet) {
   [myArray removeObject:foo];
 }
 [removeSet release];

Some alternatives:

* Iterate over the array just using an index, rather than fast enumeration (or 
NSEnumerator).  Then, you can mutate the array as you go, so long as you're 
careful about the index.  (If you remove an item on a given pass through the 
loop, then you shouldn't increment the index on that pass.)

* Collect the items to be removed by index into an NSMutableIndexSet and then 
use -removeObjectsAtIndexes: to remove them.

* Use -filterUsingPredicate:, if it's a good match for what you're trying to do

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: Keyword @defs

2009-11-30 Thread Ben Haller

On 30-Nov-09, at 4:06 PM, Bill Bumgarner wrote:


On Nov 30, 2009, at 12:50 PM, Dennis Munsie wrote:

Not that I'm advocating it, but you can also declare a field as  
@public to allow you to access it via the - operator.  Of course,  
I could be missing some compiler magic going on behind the scene as  
well, and it may not actually be the same speed wise as @defs was.


The compiler preserves the non-fragile part of non-fragile ivars  
when using the - operator.



Not to mention that it's just plain nasty :)


Yup, that it is.


  This is interesting to me, since I am in fact using @public and -  
with some ivars to allow faster use of one of my classes.  (Yes, I've  
confirmed that this is significant in Sampler; it is, in fact, quite a  
large percentage of the total time of my app, which has runtimes  
measured in days, so I do care :-).  I understand the concept of the  
fragile base class problem and so forth; I just didn't realize Apple  
had done something to fix it that might affect the performance of my  
app.  :-


  What I want is essentially a struct with methods; I need super-fast  
access to ivars for clients of the class in some places in my code.   
But I also want functionality provided by the class itself via  
methods, and I want a class hierarchy (so just using functions instead  
of methods gets ugly fast).  Is there a better solution than @public?   
Or is there some reason I shouldn't worry about it -- is all the  
overhead just on the first pass through any given code path, with back- 
patching, for example?


  I realize the dangers of breaking encapsulation, etc.  :-  But  
sometimes optimization simply demands that you do such things.  I run  
my app on a computing cluster, and time on the cluster is at a  
premium, so the headaches involved are worth it.  I just want to know  
the best way to do it, given these recent changes to Objective-C.  Any  
advice?


Ben Haller
Stick 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: iterating and removing objects from a collection

2009-11-30 Thread Sherm Pendley
On Mon, Nov 30, 2009 at 4:21 PM, Ken Thomases k...@codeweavers.com wrote:
 On Nov 30, 2009, at 2:45 PM, Dennis Munsie wrote:

 Some alternatives:

 * Iterate over the array just using an index, rather than fast enumeration 
 (or NSEnumerator).

A safe way to do that is to iterate backwards, starting at the max
index and counting down to 0. That way, removing the item at the
current index will only change the indexes of the items you've already
seen.

sherm--

-- 
Cocoa programming in Perl:
http://www.camelbones.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: Keyword @defs

2009-11-30 Thread Greg Parker
On Nov 30, 2009, at 1:33 PM, Ben Haller wrote:
 On 30-Nov-09, at 4:06 PM, Bill Bumgarner wrote:
 On Nov 30, 2009, at 12:50 PM, Dennis Munsie wrote:
 
 Not that I'm advocating it, but you can also declare a field as @public to 
 allow you to access it via the - operator.  Of course, I could be missing 
 some compiler magic going on behind the scene as well, and it may not 
 actually be the same speed wise as @defs was.
 
 The compiler preserves the non-fragile part of non-fragile ivars when 
 using the - operator.
 
 Not to mention that it's just plain nasty :)
 
 Yup, that it is.
 
  This is interesting to me, since I am in fact using @public and - with some 
 ivars to allow faster use of one of my classes.  (Yes, I've confirmed that 
 this is significant in Sampler; it is, in fact, quite a large percentage of 
 the total time of my app, which has runtimes measured in days, so I do care 
 :-).  I understand the concept of the fragile base class problem and so 
 forth; I just didn't realize Apple had done something to fix it that might 
 affect the performance of my app.  :-
 
  What I want is essentially a struct with methods; I need super-fast access 
 to ivars for clients of the class in some places in my code.  But I also want 
 functionality provided by the class itself via methods, and I want a class 
 hierarchy (so just using functions instead of methods gets ugly fast).  Is 
 there a better solution than @public?  Or is there some reason I shouldn't 
 worry about it -- is all the overhead just on the first pass through any 
 given code path, with back-patching, for example?

@public is the best way to do this. (Well, @package may be slightly better, but 
it's probably only a theoretical improvement in launch time.)

The details are CPU-specific, but non-fragile ivar access is expected to use 
two or three loads where fragile ivar access used one load.

For ObjC code like this:
x = self-YourIvar;

Fragile ivar access looks like this when compiled (in a fake assembly language 
I just made up):
load r1 = self+offsetof(YourIvar)// offsetof(YourIvar) is a 
compile-time constant

Non-fragile ivar access looks roughly like this:
load r1 = _OBJC_IVAR_$_YourClass.YourIvar
load r2 = *r1
load r3 = self+r2


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


[MEET] December CocoaHeads Mac Developer Meetings

2009-11-30 Thread Stephen Zyszkiewicz

Greetings,

CocoaHeads is an international Mac programmer's group. Meetings are  
free and open to the public. We specialize in Cocoa, but everything  
Mac programming related is welcome.


Upcoming meetings:
Australia
Sydney- Thursday, December 3, 2009 18:30.

Austria
Wien- Thursday, December 10, 2009 19:00.

Germany
Aachen- Thursday, December 17, 2009 19:00.
Berlin- Wednesday, December 9, 2009 19:00.
Munich- Thursday, December 10, 2009 19:00.
Stuttgart- Wednesday, December 9, 2009 19:00.

India
Pune- Tuesday, December 15, 2009 19:00.

Switzerland
Zürich- Wednesday, December 9, 2009 19:00.

United States
Ann Arbor- Thursday, December 10, 2009 19:00.
Atlanta- Thursday, December 10, 2009 19:00.
Birmingham- Thursday, December 10, 2009 19:00.
Boulder- Tuesday, December 8, 2009 19:00.
Colorado Springs- Thursday, December 10, 2009 19:00.
Columbus- Tuesday, December 8, 2009 19:00.
Denver- Tuesday, December 8, 2009 19:00.
Des Moines- Thursday, December 10, 2009 19:00.
Nashville- Thursday, December 10, 2009 19:00.
New York- Thursday, December 10, 2009 18:00.
Oklahoma City- Thursday, December 3, 2009 18:30.
Sacramento- Tuesday, December 1, 2009 17:00.
St. Louis- Saturday, December 19, 2009 14:00.


Some chapters may have yet to post their meeting for next month.  
Meeting times may change. Locations and more information here:

http://cocoaheads.org

Also be sure to check for an NSCoder Night in your area:
http://nscodernight.com/


Steve
Silicon Valley CocoaHeads___

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

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

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

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


Re: Keyword @defs

2009-11-30 Thread Mike Abdullah

On 30 Nov 2009, at 21:33, Ben Haller wrote:

 On 30-Nov-09, at 4:06 PM, Bill Bumgarner wrote:
 
 On Nov 30, 2009, at 12:50 PM, Dennis Munsie wrote:
 
 Not that I'm advocating it, but you can also declare a field as @public to 
 allow you to access it via the - operator.  Of course, I could be missing 
 some compiler magic going on behind the scene as well, and it may not 
 actually be the same speed wise as @defs was.
 
 The compiler preserves the non-fragile part of non-fragile ivars when 
 using the - operator.
 
 Not to mention that it's just plain nasty :)
 
 Yup, that it is.
 
  This is interesting to me, since I am in fact using @public and - with some 
 ivars to allow faster use of one of my classes.  (Yes, I've confirmed that 
 this is significant in Sampler; it is, in fact, quite a large percentage of 
 the total time of my app, which has runtimes measured in days, so I do care 
 :-).  I understand the concept of the fragile base class problem and so 
 forth; I just didn't realize Apple had done something to fix it that might 
 affect the performance of my app.  :-
 
  What I want is essentially a struct with methods; I need super-fast access 
 to ivars for clients of the class in some places in my code.  But I also want 
 functionality provided by the class itself via methods, and I want a class 
 hierarchy (so just using functions instead of methods gets ugly fast).  Is 
 there a better solution than @public?  Or is there some reason I shouldn't 
 worry about it -- is all the overhead just on the first pass through any 
 given code path, with back-patching, for example?
 
  I realize the dangers of breaking encapsulation, etc.  :-  But sometimes 
 optimization simply demands that you do such things.  I run my app on a 
 computing cluster, and time on the cluster is at a premium, so the headaches 
 involved are worth it.  I just want to know the best way to do it, given 
 these recent changes to Objective-C.  Any advice?

Could your class perhaps expose a struct or a pointer to it as a property of 
some kind? You are avoiding touching instance variables, and once the method to 
retrieve the struct is used, you can cache the result. Or even, expose the 
struct as an instance variable, giving the speed advantage of 
both.___

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

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

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

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


Re: Button width should accomodate localized string

2009-11-30 Thread Ricky Sharp

On Nov 29, 2009, at 9:52 AM, glenn andreas wrote:

 On Nov 29, 2009, at 9:38 AM, Symadept wrote:
 
 How can I scale my button or Label to be able to accomodate the localized
 string?
 
 That's the whole purpose of being able to localize the nib/xib...

Exactly.  It's not possible to create a single nib such that its layout and 
control sizes will be appropriate for every language.

Beyond control sizes being different, I've also found the following things to 
consider between flavors of your nibs:

* Font size and/or style may need to change.
* Directionality would need to change (if localizing to right-to-left languages)

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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: Polymorphic relationship and migration

2009-11-30 Thread Yi Lin

Quincey,

Thanks for the response. Shape is just a made-up example, but we can  
say the entity that contains shape is Diagram for the purpose of  
discussion. I am not sure what the mapping DiagramToShape would do.


Here's my problem in more concrete terms.

Let's say I have the entity mapping DiagramToDiagram. And one of the  
property mappings is shape. In the Relationship Mapping panel (the  
third column in the mapping model GUI), I set the KeyPath to  
$source.shape. The question is what to put in the Mapping Name  
field. If I put ShapeToShape, then the shape property will not be set  
because there are no instances of Shape. If I put TriangleToTriangle,  
then only shapes that are Triangles will be migrated. There is no  
value I can put in this field that will set the shape property  
properly for all concrete subclasses of Shape.


Yi

On Nov 29, 2009, at 3:16 AM, Quincey Morris wrote:


On Nov 27, 2009, at 17:14, Yi Lin wrote:

For example, if I have a relationship called shape that refers to  
the Shape abstract entity, with concrete classes Triangle, Square,  
etc. In the mapping model, there's no sensible setting for the  
Mapping Name field of shape. If I set the Mapping Name to  
TriangleToTriangle, then Square relationships will not be set. And  
if I set the Mapping Name to Shape, than the relationship would  
not be set at all because there are no concrete instances of Shape.


If the relationship shape is defined to be to a Shape entity, it  
seems that the correct mapping would be SomethingToShape.  
(Something is the entity from which the shape relationship  
emanates, but you didn't say what entity that was.) Even though  
there aren't any concrete instances of Shape, the actual instances  
(Triangle, Square, etc) *are* also Shape objects.


Perhaps the confusion arises because Leopard Core Data doesn't  
properly create the mappings for migrating abstract entities. (I  
don't know if this is fixed in Snow Leopard, but I suspect not.) If  
that's the problem, then adding the missing mapping should give you  
a usable mapping model.


Or have I missed your point?


___

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

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

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

This email sent to eli...@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: iterating and removing objects from a collection

2009-11-30 Thread Jens Alfke

On Nov 30, 2009, at 1:37 PM, Sherm Pendley wrote:

 A safe way to do that is to iterate backwards, starting at the max
 index and counting down to 0. That way, removing the item at the
 current index will only change the indexes of the items you've already

+1. I often use this idiom. You can do it going forwards, but it introduces an 
if/else that makes the code sort of confusing (and easy to mess up.)

It's also more efficient than removing the elements in forwards order (proof of 
this is left as an exercise for the reader.)

—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: Button width should accomodate localized string

2009-11-30 Thread Jens Alfke

On Nov 30, 2009, at 2:53 PM, Ricky Sharp wrote:

 Exactly.  It's not possible to create a single nib such that its layout and 
 control sizes will be appropriate for every language.

It's not impossible, it's just that it requires a very different approach, 
which in turn makes it a lot harder to create good-looking layouts. Overall I 
think Cocoa's approach is the right one.

For example, Java's AWT/Swing frameworks lay out views on the fly using 
LayoutManagers, taking into account text and other metrics. (I think they got 
the approach from Motif.) It's a primary reason why Java user interfaces 
usually look so ugly; and also why designing them is so difficult.

—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: Polymorphic relationship and migration

2009-11-30 Thread Quincey Morris
On Nov 30, 2009, at 14:56, Yi Lin wrote:

 Let's say I have the entity mapping DiagramToDiagram. And one of the 
 property mappings is shape. In the Relationship Mapping panel (the third 
 column in the mapping model GUI), I set the KeyPath to $source.shape. The 
 question is what to put in the Mapping Name field. If I put ShapeToShape, 
 then the shape property will not be set because there are no instances of 
 Shape. If I put TriangleToTriangle, then only shapes that are Triangles will 
 be migrated. There is no value I can put in this field that will set the 
 shape property properly for all concrete subclasses of Shape.

I believe ShapeToShape *is* the correct mapping. Are you saying it doesn't 
work, or just that you don't think it will work?

My earlier point is that there *are* instances of entity Shape -- in the 
sense that there are instances that are a kind of Shape, even though their 
actual class might be Triangle or Square. This is analogous to the difference 
between the 'isKindOfClass:' and 'isMemberOfClass:' methods in Cocoa, and the 
mapping uses a kind of test, not a member of test.

I have been successful with just such a mapping in the past. I had a tree 
structure, so the abstract Node entity had parent and children 
relationships. Using a NodeToNode mapping migrated the children relationship 
properly, even the the children were actually of subentities of Node.

Note that using NodeToNode did *not* mean that the objects were changed to 
entity Node on migration. They stayed as whatever they were supposed to be.


___

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

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

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

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


Re: Keyword @defs

2009-11-30 Thread Ben Haller

On 30-Nov-09, at 5:52 PM, Mike Abdullah wrote:


On 30 Nov 2009, at 21:33, Ben Haller wrote:

What I want is essentially a struct with methods; I need super-fast  
access to ivars for clients of the class in some places in my  
code.  But I also want functionality provided by the class itself  
via methods, and I want a class hierarchy (so just using functions  
instead of methods gets ugly fast).  Is there a better solution  
than @public?  Or is there some reason I shouldn't worry about it  
-- is all the overhead just on the first pass through any given  
code path, with back-patching, for example?


I realize the dangers of breaking encapsulation, etc.  :-  But  
sometimes optimization simply demands that you do such things.  I  
run my app on a computing cluster, and time on the cluster is at a  
premium, so the headaches involved are worth it.  I just want to  
know the best way to do it, given these recent changes to Objective- 
C.  Any advice?


Could your class perhaps expose a struct or a pointer to it as a  
property of some kind? You are avoiding touching instance variables,  
and once the method to retrieve the struct is used, you can cache  
the result. Or even, expose the struct as an instance variable,  
giving the speed advantage of both.


  That's an interesting idea, Mike.  I think I will look into it.   
Thanks (and thanks too to Greg Parker for his also illuminating post)!


Ben Haller
Stick 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


copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Mario Kušnjer

Hi !

I have some trouble understanding this implementation:

- copyWithZone:(NSZone *)zone
{
ImageAndTextCell *cell = (ImageAndTextCell *)[super  
copyWithZone:zone];

cell-image = [image retain];
return cell;
}

It is from the Apple's sample code.

First question is why there is no return type declared in front of  
copyWithZone: (probable - id - type) ?
Second question is what this sign stands (means) for: - (in cell- 
image = [image retain];) ?
Could that line be written somehow different (like any other objc  
message) ?


Basically, I'm asking for a child-like explanation of this  
implementation.

Thanks for your answers in advance. Bye.


Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

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

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

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


Re: removing all sublayers from a layer with fast enumeration

2009-11-30 Thread Matt Neuburg
On Mon, 30 Nov 2009 14:45:04 -0500, Dave Keck davek...@gmail.com said:
Is the crash due to an exception? Is anything printed to stdout?

No, that's part of what's so weird. If we were going to throw an exception,
I'd expect to see a coherent explanation in the log. However, the call chain
does show we're in something called NSFastEnumerationMutationHandler. Is it
worth filing a bug, asking for some sort of log message? m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
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: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Clark Cox
2009/11/30 Mario Kušnjer mario.kusn...@sb.t-com.hr:
 Hi !

 I have some trouble understanding this implementation:

 - copyWithZone:(NSZone *)zone
 {
    ImageAndTextCell *cell = (ImageAndTextCell *)[super copyWithZone:zone];
    cell-image = [image retain];
    return cell;
 }

 It is from the Apple's sample code.

 First question is why there is no return type declared in front of
 copyWithZone: (probable - id - type) ?

If you don't declare a return type for a method, it defaults to id

 Second question is what this sign stands (means) for: - (in cell-image =
 [image retain];) ?

cell-image is semantically identical to (*cell).image. That is, it's
directly accessing the instance variable image of the object cell

 Could that line be written somehow different (like any other objc message) ?

In most cases, yes. However, copyWithZone: is special, the superclass'
implementation just blindly copies all of the raw bits in the source
object to the newly created one. If you were to use the normal
-setImage: call, that old value would be released one too many times.
Assigning to the instance variable in this case is the way to avoid
that.



 Basically, I'm asking for a child-like explanation of this implementation.
 Thanks for your answers in advance. Bye.


 Mario Kušnjer
 mario.kusn...@sb.t-com.hr
 +385957051982



 ___

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

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

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

 This email sent to clarkc...@gmail.com




-- 
Clark S. Cox III
clarkc...@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: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Jeff Laing
 In most cases, yes. However, copyWithZone: is special, the superclass'
 implementation just blindly copies all of the raw bits in the source
 object to the newly created one. If you were to use the normal
 -setImage: call, that old value would be released one too many times.
 Assigning to the instance variable in this case is the way to avoid
 that.

Why would you not just do:

[cell-image retain];

That makes it a lot clearer to me - since it was a bitwise copy, cell-image 
and image are identical values whereas the assignment looks like you are 
changing something.

___

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

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

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

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

Re: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Mario Kušnjer

cell-image is semantically identical to (*cell).image. That is, it's
directly accessing the instance variable image of the object cell



This part is what trouble's me.

cell-image = [image retain];

This could not be like this, right ?

[cell image] = [image retain];


Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

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

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

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


totally baffled by odoc apple event failing on launch

2009-11-30 Thread David M. Cotter
Coca64 only:

recently our app has stopped responding to odoc apple events on startup.  
that is, if the user double clicks a document of our app, and this causes the 
app to launch, then the document is not opened. (cnr when app is already 
launched).  same story dropping the doc icon onto the app icon (same code path).

this functionality stopped working just recently.  it was working before, now 
it's not.  our suspicion is a new component during startup is eating the events 
 (presume for the sake of this question that this can not be changed)

in the olden days of Carbon, we had a similar problem, maybe the exact same 
problem.  to solve it then, right at the very start of app init we would 
manually forcibly loop GetNextEvent(highLevelEvent) and store them all off in a 
vector.  then do our (lengthy) startup procedure (which could suck up events), 
then when we're all done, loop over the vector and handle all the high level 
events.  this worked like a charm.  strange, but it worked.

now i think we may need to do this again, but in Cocoa land. 

how do i manually pull these events out of the que? sincse there is no 
GetNextEvent().___

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

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

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

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


Re: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Graham Cox

On 01/12/2009, at 12:26 PM, Jeff Laing wrote:

 In most cases, yes. However, copyWithZone: is special, the superclass'
 implementation just blindly copies all of the raw bits in the source
 object to the newly created one. If you were to use the normal
 -setImage: call, that old value would be released one too many times.
 Assigning to the instance variable in this case is the way to avoid
 that.
 
 Why would you not just do:
 
   [cell-image retain];
 
 That makes it a lot clearer to me - since it was a bitwise copy, cell-image 
 and image are identical values whereas the assignment looks like you are 
 changing something.


You don't know that it was a bitwise copy - it depends on super's 
implementation. If you assume it was, you'll probably be wrong.

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


Some questions/problems regarding CALayers

2009-11-30 Thread Henri Häkkinen
Hello.

I'm trying to implement my custom NSView derived class to draw a chessboard 
with chess pieces on it. I'm using Core Animation's CALayer classes since I 
want to use animation with other effects later on.

Currently I have have Board and Piece classes, which both derive from CALayer. 
Board overrides resizeWithSuperlayerSize which resizes bounds to always keep 
the layer's aspect ratio fixed (since chessboards are always square) and it's 
position centered relative to the superlayer's frame, and in drawInContext I 
draw the chess squares with two alternating colors. Piece class likewise 
overrides drawInContext to draw NSImage on it, which represents piece's vector 
image loaded from a PDF file. Board layer is added as a sublayer of the 
NSView's root layer and Piece layers are added as a sublayer of the Board layer 
and so forth.

My problem now is, however, that I am not sure how do I keep the position and 
size of a Piece layer fixed to a specific square in the Board layer. Board's 
bounding rectangle can be any size and it changes dynamically as the view gets 
resized. Piece layer does not know it's square coordinates on the chessboard, 
except by the bounds rectangle.

I tried using two methods:

a) using autoresizeMask on a Piece layer with kCALayerWidthSizable | 
kCALayerHeightSizable

b) using sublayerTransform on the Board layer and then using a 2D scaling 
matrix to define a virtual coordinate space of (0, 0, 8, 8) where (0, 0) 
corresponds to the lower left and (8, 8) corresponds the top right corner of 
the board (this would be ideal since placing pieces on squares would be easy)


Neither of these didn't work very well. By using kCALayerWidthSizable | 
kCALayerHeightSizable doesn't keep the size of a Piece in synch with the Board 
somehow, and by using sublayerTransform  makes the piece images aliased since 
they are rasterized in very low resolution and then scaled up using pixel 
transformations (rather than by transforming the coordinate space of the vector 
image).

Can anyone recommend me any better way? And by the way, I am using NSImage 
rather than CGImageRef because it seems that Core Graphics images only supports 
raster images. Perhaps a better way would be using OpenGL to draw the 
chessboard altogether instead of using Cocoa/Core Graphics. But then again, I 
wouldn't be able to use Core Animation effects ...

Henri H.

___

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

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

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

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


Re: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Graham Cox

On 01/12/2009, at 12:30 PM, Mario Kušnjer wrote:

 This could not be like this, right ?
 
 [cell image] = [image retain];


No, because [cell image] returns a value, it does not set a value. You might 
consider doing this though:

[cell setImage:image];

Clark is right that if the copy was a bitwise copy, this is going to 
over-release (or insufficiently retain, same thing), but assuming the presence 
of a bitwise copy that is not explicitly documented as such is an assumption 
too far.

The docs for NSCopying state that a copy can be implemented by:

• Implement NSCopying using alloc and init... in classes that don’t 
inherit copyWithZone:.
• Implement NSCopying by invoking the superclass’s copyWithZone: when 
NSCopying behavior is inherited. If the superclass implementation might use the 
NSCopyObject function, make explicit assignments to pointer instance variables 
for retained objects.
• Implement NSCopying by retaining the original instead of creating a 
new copy when the class and its contents are immutable.

So doing this:

cell-image = [image retain];

is actually the safest thing to do, because it works correctly whether or not 
the superclass used NSCopyObject, so no assumptions about the superclass 
implementation has to be made. I still feel that NSCopyObject is a nasty 
dangerous function though, and for my own classes I never implement copy that 
way.

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


NSAffineTransform scaleBy not scaling

2009-11-30 Thread Shane
Hey all,

I'm drawing a graphing line, looks like a wave within an NSView. The
line looks fine, except that it's not scaled to the size of the
window. So my problem is trying to figure out how to scale it to the
window size and every time that the window is resized.

I currently have something like below, but my 'scaleXBy, yBy' on the
NSAffineTransform isn't working out so well.

Anyone see what I'm doing wrong here, or know how to get the
NSBezierPath to take up 90% of my NSView (leaving 10% blank for
borders which is what I tried to do below)?

- (void) drawRect:(NSRect) rect
{
NSRect bounds = [self bounds];

float xAxis = bounds.size.width * 0.9;
float yAxis = bounds.size.height * 0.9;

[[NSColor blackColor] setFill];
[NSBezierPath fillRect:bounds];

NSAffineTransform *newTransform = [NSAffineTransform transform];
[newTransform translateXBy:40.0 yBy:30.0];
[newTransform concat];  

// can't seem to get this transform to work as expected.
[newTransform scaleXBy:xAxis yBy:yAxis];

[self drawAxes:rect width:xAxis height:yAxis];
[self drawGraph:rect];

return;
}
___

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

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

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

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


Re: totally baffled by odoc apple event failing on launch

2009-11-30 Thread David M. Cotter
i see theres this NSAppleEventManager, and that with that you can suspend an 
event and resume it later.  i think this is what i want.

but how do I get my app to force all these events to get sent (and therefore 
handled) on demand (before i go thru loading all the startup stuff)?  i can 
only suspend an event if it's being handled. the problem is my app never gets 
to handle them.

On Nov 30, 2009, at 5:33 PM, David M. Cotter wrote:

 Coca64 only:
 
 recently our app has stopped responding to odoc apple events on startup.  
 that is, if the user double clicks a document of our app, and this causes the 
 app to launch, then the document is not opened. (cnr when app is already 
 launched).  same story dropping the doc icon onto the app icon (same code 
 path).
 
 this functionality stopped working just recently.  it was working before, now 
 it's not.  our suspicion is a new component during startup is eating the 
 events  (presume for the sake of this question that this can not be changed)
 
 in the olden days of Carbon, we had a similar problem, maybe the exact same 
 problem.  to solve it then, right at the very start of app init we would 
 manually forcibly loop GetNextEvent(highLevelEvent) and store them all off in 
 a vector.  then do our (lengthy) startup procedure (which could suck up 
 events), then when we're all done, loop over the vector and handle all the 
 high level events.  this worked like a charm.  strange, but it worked.
 
 now i think we may need to do this again, but in Cocoa land. 
 
 how do i manually pull these events out of the que? sincse there is no 
 GetNextEvent().
___

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

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

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

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


Re: NSAffineTransform scaleBy not scaling

2009-11-30 Thread Stephen J. Butler
On Mon, Nov 30, 2009 at 7:55 PM, Shane
software.research.developm...@gmail.com wrote:
 Anyone see what I'm doing wrong here, or know how to get the
 NSBezierPath to take up 90% of my NSView (leaving 10% blank for
 borders which is what I tried to do below)?

You call concat before you apply the scale. Do the translate, scale,
and then concat.

 - (void) drawRect:(NSRect) rect
 {
        NSRect bounds = [self bounds];

        float xAxis = bounds.size.width * 0.9;
        float yAxis = bounds.size.height * 0.9;

        [[NSColor blackColor] setFill];
        [NSBezierPath fillRect:bounds];

        NSAffineTransform *newTransform = [NSAffineTransform transform];
        [newTransform translateXBy:40.0 yBy:30.0];
        [newTransform concat];

        // can't seem to get this transform to work as expected.
        [newTransform scaleXBy:xAxis yBy:yAxis];

        [self drawAxes:rect width:xAxis height:yAxis];
        [self drawGraph:rect];

        return;
 }
 ___

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

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

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

 This email sent to stephen.but...@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: NSAffineTransform scaleBy not scaling

2009-11-30 Thread Graham Cox

On 01/12/2009, at 12:55 PM, Shane wrote:

 I'm drawing a graphing line, looks like a wave within an NSView. The
 line looks fine, except that it's not scaled to the size of the
 window. So my problem is trying to figure out how to scale it to the
 window size and every time that the window is resized.
 
 I currently have something like below, but my 'scaleXBy, yBy' on the
 NSAffineTransform isn't working out so well.
 
 Anyone see what I'm doing wrong here, or know how to get the
 NSBezierPath to take up 90% of my NSView (leaving 10% blank for
 borders which is what I tried to do below)?
 
 - (void) drawRect:(NSRect) rect
 {
   NSRect bounds = [self bounds];
 
   float xAxis = bounds.size.width * 0.9;
   float yAxis = bounds.size.height * 0.9;
   
   [[NSColor blackColor] setFill];
   [NSBezierPath fillRect:bounds];
 
   NSAffineTransform *newTransform = [NSAffineTransform transform];
   [newTransform translateXBy:40.0 yBy:30.0];
   [newTransform concat];  
 
   // can't seem to get this transform to work as expected.
   [newTransform scaleXBy:xAxis yBy:yAxis];
 
   [self drawAxes:rect width:xAxis height:yAxis];
   [self drawGraph:rect];
 
   return;
 }


You concat your transform, then change its scale. The scale change will have no 
effect because you already did the concat. (n.b. a concat just multiplies the 
current graphics context transform by yours, so changes you make to yours later 
don't have an effect).

However, I think your maths is wrong also.

You need to take into account the size of the path you're trying to draw. If 
your path has a bounds of, say, 100 x 100, and you wish to fit it into your 
view's bounds, the scale factor on each axis will be view.bounds / path.bounds. 
So if your view is 200 x 150, you end up with scale factors of 2 and 1.5 
respectively. You also need to carefully consider  where the origin is - if 
translate before you scale, the scale will also scale the offset, maybe not 
what you want. But the order of operations you apply to the transform is the 
reverse of what you might think will happen. One way to simplify the maths 
slightly is to generate the graph path using a fixed reference bounds of 1 x 1, 
located at the origin. Then you can directly use your view's size and position 
to scale and translate.

--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: Hiding String Constant in Compiled Code

2009-11-30 Thread Rob Keniger

On 01/12/2009, at 4:05 AM, Richard Somers wrote:

 I could be wrong but I do not think this is the case. The documentation 
 states Once you have signed your code, any change in the code that you did 
 not intend—whether introduced accidently or by hackers—can be detected by the 
 system. No where does it say the system will not run the altered code.


Launchd will terminate the application on launch if a change is detected, 
provided you sign the application with the -kill flag.

However, as Jens points out, this is not a solution.

--
Rob Keniger



___

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

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

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

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


Re: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Mario Kušnjer

Thank you for your explanations, Clark, Jeff and Graham.

I think i will go now and read a C book (yes, I know I should have  
read it by now) because it seems to me I have been missing something.

Bye


Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

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

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

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


Re: totally baffled by odoc apple event failing on launch

2009-11-30 Thread Dave Keck
I'd imagine NSApp's delegate method -application:openFile: is what you
should be using, unless there's a reason you need to handle the raw
Apple event.
___

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

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

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

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


Carbon menus in Cocoa app

2009-11-30 Thread Vikram Sethi
Hi,

I have a Carbon app that I am moving to Cocoa. In an attempt to do that, I
wrote code similar to this in the main function:

[NSApplication sharedApplication];

…

…

[NSApp run];

All the event handling in currently Carbon based. I was expecting problems
but after the changes, the app launched fine. There were a few small issues
related to app quit, but those were easy to fix. I was able to create a new
document and save it too.

*The Problem:*

Though the menu bar appears and the individual menu items get created and
get added to the hierarchy (verified it while debugging), the menus do not
open when I click on the menu bar. The menus are also Carbon based. They are
defined as a ‘MBAR’ resource and the menu bar gets created using the
GetNewMBar() API. This API has been marked ‘Not recommended’ though it is
not deprecated. Documentation says use NIB files instead.

I tried similar changes in another Carbon based app. This app opened fine
and I was able to access the menus also. Unlike my app, this ref app defines
the menus in a NIB file and creates the menu bar using the NIB file.

-  I understand that we should move our menu handling to Cocoa and
that would resolve the problem. We will do that, however, we plan to
modernize our app incrementally, taking one step at a time. Is there a low
cost tweak/hack that we can put in for now to make the menus work so that we
can revamp the menu handling a little later?

-  Has anybody else faced similar problems? Were you able to solve
it?


Any help would be appreciated.



Thanks in advance,

Vikram Sethi
___

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

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

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

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


What to subclass in NSArrayController to enable immediate editing of added rows?

2009-11-30 Thread David Hirsch
I have read about this online, but I can't find a solution that (a)  
works and (b) seems wise.
I'm trying to have my table immediately enable editing of added  
items.  The NSTableView is bound to an NSArrayController.  I've  
subclassed NSArrayController, and tried this first:


- (void)add:(id)sender {
[super add:sender];
NSInteger numRows = [myTable numberOfRows];
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex:numRows-1];
[myTable selectRowIndexes:indexes byExtendingSelection:NO];
[myTable editColumn:0 row:numRows-1 withEvent: nil select:YES];
}

Now, leaving aside the issues surrounding sorting of the arrays, and  
possibly getting the WRONG item selected for editing, this fails  
because, as the docs state, the results of the add: method are delayed  
until the next runloop.  So a cell starts editing for an instant, but  
then as soon as the next runloop occurs, the new cell really gets  
added, and then is not enabled for editing.


Here is what I tried next.  It works, but I don't like it, because it  
doesn't call [super add], which seems like a bad idea - what if new  
functionality gets put into that method in the future?

- (void)add:(id)sender {
// Adapted from 
http://stackoverflow.com/questions/844933/move-focus-to-newly-added-record-in-an-nstableview
//Try to end any editing that is taking place in the table view
NSWindow *w = [myTable window];
BOOL endEdit = [w makeFirstResponder:w];
if(!endEdit)
return;

//Create a new object to add to your NSTableView; replace NSString with
//whatever type the objects in your array controller are
Room *new = [self newObject];

//Add the object to your array controller
[self addObject:new];
[new release];

//Rearrange the objects if there is a sort on any of the columns
[self rearrangeObjects];

	//Retrieve an array of the objects in your array controller and  
calculate

//which row your new object is in
NSArray *array = [self arrangedObjects];
int row = [array indexOfObjectIdenticalTo:new];

//Begin editing of the cell containing the new object
[myTable editColumn:0 row:row withEvent:nil select:YES];
}

I've read methods of handling this (e.g., the link from which the  
above code was adapted, http://www.friday.com/bbum/2006/05/18/core-data-array-controller-edit-on-insert/ 
) that rely on actions in the document subclass, but I have to do this  
for a number of different tables/controllers in my document and I'd  
like to encapsulate the functionality in the NSArrayController  
subclass instead of the document.


Should I be subclassing a different method that is not delayed?   
addObject?  Is there a better strategy altogether?


Thanks,
Dave



Dave Hirsch
Associate Professor
Department of Geology
Western Washington University
persistent email: dhir...@mac.com
http://www.davehirsch.com
voice: (360) 389-3583
aim: dhir...@mac.com
vCard: http://almandine.geol.wwu.edu/~dave/personal/DaveHirsch.vcf




___

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

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

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

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


Re: NSAffineTransform scaleBy not scaling

2009-11-30 Thread Shane
Just adding the other methods for clarification.

- (void) drawAxes:(NSRect) rect
{
NSRect bounds = [self bounds];

NSBezierPath *path = [NSBezierPath bezierPath];

[path moveToPoint:NSMakePoint(0.1, 0.0)];
[path lineToPoint:NSMakePoint((bounds.size.width * 0.95), 0.0)];

[path moveToPoint:NSMakePoint(0.0, 0.1)];
[path lineToPoint:NSMakePoint(0.0, (bounds.size.height * 0.95))];

[[NSColor grayColor] setStroke];
[path stroke];

return;
}

- (void) drawError:(NSRect) rect
{   
[[NSColor whiteColor] setStroke];   
[pointsPath setLineCapStyle:NSSquareLineCapStyle];
[pointsPath stroke];

return;
}
___

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

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

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

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


Re: How to draw text to bitmap (array) with pre 10.5 libs

2009-11-30 Thread Glenn McCord
Thanks for all the feedback guys. I got it to work using the NSString
drawWithRect.
For the sake of all those who stumble across this thread, the code
used (minus lots of font and string code) is as follows...

unsigned char* bitmapData = 0;

NSBitmapImageRep* rep = [[[NSBitmapImageRep alloc]
  
initWithBitmapDataPlanes:bitmapData  // Single plane; just
our bitmapData
  
pixelsWide:width
  
pixelsHigh:height
  
bitsPerSample:8
  
samplesPerPixel:4
  hasAlpha:YES
  isPlanar:NO
  
colorSpaceName:NSCalibratedRGBColorSpace
  bytesPerRow:0 
 // Let it compute bytesPerRow and bitsPerPixel
  
bitsPerPixel:0] autorelease];


[NSGraphicsContext saveGraphicsState];
NSGraphicsContext* context = [NSGraphicsContext
graphicsContextWithBitmapImageRep:rep];
[NSGraphicsContext setCurrentContext:context];

NSPoint origin = {0, 0};
NSSize size = {width, height};
NSRect rect = {origin, size};

[nsString drawWithRect:rect
options:NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin
attributes:nsAttributes];

[NSGraphicsContext restoreGraphicsState];

returnData = [rep bitmapData];


And provided everything works as it should, returnData will contain
all the raw data of the bitmap.

Thanks



On Tue, Dec 1, 2009 at 5:54 AM, Adam R. Maxwell amaxw...@mac.com wrote:

 On Nov 29, 2009, at 10:01 PM, John Horigan wrote:


 On Nov 29, 2009, at 9:09 PM, Graham Cox wrote:


 On 30/11/2009, at 2:44 PM, Glenn McCord wrote:

 What I'm expecting is the drawAtPoint method to draw nsString inside
 the bitmapRep of the NSContext at which point I can retrieve the raw
 data  and do something with it. On account of the data all being zero,
 I'm obviously doing something wrong and would really appreciate some
 advice.


 You also have to lock focus on the bitmap, which requires that it first be 
 added to an NSImage (I think if you are targeting 10.6 only there is a new 
 API that means you can avoid this).

 The OP was creating an NSGraphicsContext and making it the current drawing 
 context, so I don't see a need to muck around with NSImage.  The docs do say 
 that you should only use -[NSString drawAtPoint:attributes:] when an NSView 
 has focus, though.  I know I've used -[NSString 
 drawWithRect:options:attributes:] to draw to a bitmap context, so I'd give 
 that a try (and be wary of the origin and flippedness of the context).

 Also, it's not necessary to allocate the bitmap's buffer - if you don't 
 pass one, it will allocate it for you.

 --Graham


 Indeed, the initWithBitmapDataPlanes method treats the supplied buffer as 
 immutable and creates its own internal copy.

 This is not correct.  From the docs [1]:

 If planes is not NULL and the array contains at least one data pointer, the 
 returned object will only reference the image data; it will not copy it. The 
 object treats the image data in the buffers as immutable and will not attempt 
 to alter it. When the object itself is freed, it will not attempt to free the 
 buffers.

 Because of this, it's generally easier to let NSBitmapImageRep create the 
 buffer for you, at least if you're going to be keeping it around.

 You must request the bitmap back from the NSBitmapImageRep using the 
 bitmapData method. Prior to 10.6 the data backing up the NSBitmapImageRep 
 was a bitmap plane but in 10.6 the cocoa team changed the backing data for 
 NSBitmapImageRep to a CGImage. Either way, you should treat the data 
 returned by bitmapData as read-only (in case you were thinking of modifying 
 it).

 My understanding is that this only applies if you create the bitmap rep with 
 initWithCGImage: (which is an odd limitation to keep track of).  You can 
 still modify bitmap data from ordinary NSBitmapImageRep instances, but it 
 will be slow since NSBitmapImageRep has to recache.  Of course, this is just 
 my interpretation of the release notes [2] so I'd be interested in 
 information to the contrary.

 [1] 
 

Re: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Clark S. Cox III



Sent from my iPhone

On Nov 30, 2009, at 17:26, Jeff Laing jeff.la...@spatialinfo.com  
wrote:


In most cases, yes. However, copyWithZone: is special, the  
superclass'

implementation just blindly copies all of the raw bits in the source
object to the newly created one. If you were to use the normal
-setImage: call, that old value would be released one too many times.
Assigning to the instance variable in this case is the way to avoid
that.


Why would you not just do:

   [cell-image retain];

That makes it a lot clearer to me - since it was a bitwise copy,  
cell-image and image are identical values whereas the assignment  
looks like you are changing something.


Because it may *not* have been a bitwise copy. The superclass may have  
either done a bitwise copy of the whole object (the common case, I  
believe) or it may have only copied its *own* instance variables (in  
which case, cell-image will be nil). It's because of this uncertanty  
of which method the superclass uses that this, admittedly ugly, bit of  
code is used.


Generally, this is only an issue for people implementing copyWithZone:  
on an object that does not inherit directly from NSObject. 
___


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

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

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

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


Re: NSAffineTransform scaleBy not scaling

2009-11-30 Thread Graham Cox

On 01/12/2009, at 3:21 PM, Shane wrote:

 I'm trying to keep the stroke path
 the same size, even thought I resize and scale the entire NSBezierPath
 to the view size. Having a little trouble figuring out how to do this.


Instead of concatenating your transform to the current graphics context, 
transform the bezier path itself, using [NSBezierPath 
transformUsingAffineTransform:]

That will scale the path to the view rather than the view to the path, so the 
point size will be the same. You'll need to regenerate a new path for each plot 
though, as the path will be permanently changed by the above.

--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: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Jeff Laing
  Why would you not just do:
 
 [cell-image retain];
 
  That makes it a lot clearer to me - since it was a bitwise copy,
  cell-image and image are identical values whereas the assignment
  looks like you are changing something.
 
 Because it may *not* have been a bitwise copy. The superclass may have
 either done a bitwise copy of the whole object (the common case, I
 believe) or it may have only copied its *own* instance variables (in
 which case, cell-image will be nil). It's because of this uncertanty
 of which method the superclass uses that this, admittedly ugly, bit of
 code is used.

Ah, the penny drops.  You're saying that the superclass might have used, 
pseudo-codingly,

memcpy( newobj, oldobj, sizeof(typeof(oldobj)) )

rather than

memcpy( newobj, oldobj, sizeof(oldclass) )

and thus the newly created object *might* have essentially random bits in the 
subclass instance variables.  I was assuming it was always going to use the 
latter - seems stupid to use the former under any circumstance.  It's never 
going to be valid for a superclass to make assumptions about the behavior of 
its subclasses, and thus it's completely irrational to present them with an 
indeterminate state, when it could just as easily promise all your instance 
variables will be nil.
___

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

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

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

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


Re: totally baffled by odoc apple event failing on launch

2009-11-30 Thread David M. Cotter
yes i have that method.  i'm just saying it is not being called in this case.  
the event is never received by the app on startup.
if i double click the icon AFTER startup, it works fine.

On Nov 30, 2009, at 6:50 PM, Dave Keck wrote:

 I'd imagine NSApp's delegate method -application:openFile: is what you
 should be using, unless there's a reason you need to handle the raw
 Apple event.

___

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

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

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

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


Re: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Clark Cox
On Mon, Nov 30, 2009 at 9:57 PM, Jeff Laing jeff.la...@spatialinfo.com wrote:
  Why would you not just do:
 
     [cell-image retain];
 
  That makes it a lot clearer to me - since it was a bitwise copy,
  cell-image and image are identical values whereas the assignment
  looks like you are changing something.

 Because it may *not* have been a bitwise copy. The superclass may have
 either done a bitwise copy of the whole object (the common case, I
 believe) or it may have only copied its *own* instance variables (in
 which case, cell-image will be nil). It's because of this uncertanty
 of which method the superclass uses that this, admittedly ugly, bit of
 code is used.

 Ah, the penny drops.  You're saying that the superclass might have used, 
 pseudo-codingly,

Yes; I've put some slightly less-psuedo code below :)

        memcpy( newobj, oldobj, sizeof(typeof(oldobj)) )

More accurately, the superclass' -copyWithZone: would look something like:

-(id)copyWithZone:(NSZone*)zone {
MySuperClass *result = [[self alloc] init];

/* Set up MySuperClass' instance variables, but don't touch
subclass' instance variables; leaving them set to nil*/

return result;
}


 rather than

        memcpy( newobj, oldobj, sizeof(oldclass) )

Or, in this case, it would look like:
-(id)copyWithZone:(NSZone*)zone {
MySuperClass *result = NSCopyObject(self, 0, zone);

/* Fix up MySuperClass' instance variable retain counts, but don't
touch subclass' instance variables; leaving them set to valid, but
under-retained values*/

return result;
}

 and thus the newly created object *might* have essentially random bits

Not random bits; there are only two possible states: it will either
have nil, in which case:
[cell setImage: image] would be just fine and:
[cell-image retain] would not work
Or an un-retained bitwise copy of the original's value, in which case:
[cell setImage: image] would not work (i.e. cause an under-retain) and:
[cell-image retain] would be fine

cell-image = [image retain], however, works in both cases.

 in the subclass instance variables.  I was assuming it was always going to 
 use the latter - seems
 stupid to use the former under any circumstance.  It's never going to be 
 valid for a superclass to
 make assumptions about the behavior of its subclasses, and thus it's 
 completely irrational to
 present them with an indeterminate state, when it could just as easily 
 promise all your instance
 variables will be nil.

True, but history is a powerful force. This is also why the
documentation on NSCopyObject states:

This function is dangerous and very difficult to use correctly. It's
use as part of copyWithZone: by any class that can be subclassed, is
highly error prone. Under GC or when using Objective-C 2.0, the zone
is completely ignored.

This function is likely to be deprecated after Mac OS X 10.6.

-- 
Clark S. Cox III
clarkc...@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