-decodeBase64 method for NSString: problems

2008-10-15 Thread Vitaly Ovchinnikov
Hello list,

I use base64 encoding to send license information to users. So, when
he enters it to the application, I need to decode and analyze it.
Since there is no standard solution for this in Cocoa, I found few
implementations in the Internet and used one. This one:
http://www.cocoadev.com/index.pl?BaseSixtyFour
(see -decodeBase64WithNewlines method).

It worked fine till yesterday, when I received an error report from
one user, who works on Tiger (10.4.11). On his Mac this method
returned empty NSData. I tried his key on my Mac - it worked without a
problem (I have OS X 10.5). Key was created using openssl, so I don't
think that it is bad.

I switched to another algorithm, the same link, but
-dataWithBase64EncodedString method. It works fine on my Mac too,
right now I'm waiting for the user's reply.

Did anybody have the same problem? Any ideas? I don't believe that
Tiger has lack of base64 support in openssl.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTask not cleaning up it's threads

2008-10-15 Thread C. Tearpak
Thanks for your insight, Ken. It's very possible that you are right,  
though I haven't tried your suggestions, especially since you are  
mentioning the "wait" parameter. I am normally a C# / .NET programmer  
by day, with other experience in Java, so the RunLoop and Timer are  
still somewhat foreign concepts to me, and when looking at threading,  
having control via the NSThread is more familiar and less weird to me.  
Hopefully, that will change, as I have seen APIs that require doing  
work via RunLoops and I have run in to issues when an NSThread created  
by me needs to interact with one.


I seem to have solved the problem. It seems like, after some  
tinkering, adding a [task waitUntilExit]; before exiting the  
runCommand method fixes the thread leak.



I suppose  it could be the fact that NSTask is "creating a separate  
executable entity" per the NSTask documentation, and that, even though  
it does not share memory space with my process, it would need to  
communicate via the pipe that was configured for stdout. If the  
objects created in that method were cleaned up and it could no longer  
communicate via the pipe or whatever, it might just leak and not know  
how or when to terminate itself That's what it seems like, anyhow.


If anyone has any insight as to the actual reason that this would be  
happen and could shed light, I would definitely like to know what is  
actually going on to gain a better understanding of the underlying  
APIs and their interactions with executables and the environment.



--Chris


On Oct 14, 2008, at 10:46 PM, Ken Thomases wrote:


On Oct 14, 2008, at 6:43 AM, C Tearpak wrote:

The following is a test application that demonstrates what I am  
seeing. If
you look at the application in Activity monitor, you will see the  
threads go

up every second.

Is there something that I am missing? For a long-running  
application that
has the following in a thread loop, this causes a huge issue, as I  
can't
seem to get these threads to clean up. I have also tried dealloc(),  
setting
the pointers to nil and NULL, and calling -terminate: on the NSTask  
before I

exit the runCommand:: method;

[...]
int main (int argc, const char * argv[]) {


mainTest* mainT = [mainTest new];

   while(true)

{

NSLog([mainT runCommand: @"/bin/date" withArguments:[NSArray new]]);

sleep(1);

}


Have you tried using a run loop and a timer to perform this  
operation once a second, rather than a while loop and sleep()?


I suspect that the threads being created by NSTask and/or  
NSFileHandle are trying to interact with the main thread using  
something like -performSelectorOnMainThread:... with YES for the  
"wait" parameter.  That requires that the main thread's run loop  
gets run in the specified mode (likely the default mode).


You can use Activity Monitor's Sample Process feature to get a sense  
of what the extraneous threads are stuck waiting for.


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 [EMAIL PROTECTED]


Re: Not so long filenames

2008-10-15 Thread Gerriet M. Denkmann


On 14 Oct 2008, at 23:43, Sean McBride wrote:


On 10/14/08 5:28 PM, Gerriet M. Denkmann said:


But in the program below there seems to exist some other limit (at
least on 10.4.11 Tiger).
Where is this documented?
Or what am I doing wong?


#import 

int main (int argc, const char * argv[])
{
  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

  NSData *data = [ @"Some Data" dataUsingEncoding:
NSUTF8StringEncoding ];
  NSFileWrapper *aWrapper = [ [ NSFileWrapper alloc ]
initRegularFileWithContents: data ];
NSString *f2 = [ NSString stringWithUTF8String: //  64 * 
DESERET
CAPITAL LETTER LONG I
 
   "???
??
??
?"// 64
];


Are you trying to create a constant NSString with UTF8 characters in
your source?  Is that what all the '?' chars are?
The '?' were (before being mangled by some silly mail software)  
DESERET CAPITAL LETTER LONG I.



  You can only do that in 10.5.


Well, I not only tried but did this successfully in 10.4. The  
documentation says about stringWithUTF8String: "Available in Mac OS X  
v10.0 and later."
What is new in 10.5 is: NSString *s = @"string with more than just  
plain Ascii";


But this is not my question. It is about how to measure the  
acceptable length of a filename.


A filename must not be longer than 255. Ok.
But what is the length of a filename?
The number of characters obviously. But what is a character?

A graphem? Then my string has a length of 64.

The number of shorts in Utf-16 (this is what -[NSString length]  
returns)? This is the metric used by Finder and HFS+  (see  
HFSUniStr255 in /usr/include/hfs/hfs_format.h). Using this metric my  
string has a length of 128.


Or the number of bytes in Utf-8 ( strlen( [path  
fileSystemRepresentation] ) )? This seems to be the case in my  
program. With this metric my string a a length of 256.


So again: how and where is the acceptable length of a filename defined?


Kind regards,

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread Jean-Daniel Dupas

Use Distributed Object, there is plenty of sample codes.

Le 15 oct. 08 à 12:43, han a écrit :


how to complete a c/s app.Is there a sample code?
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Comparing the Class

2008-10-15 Thread Ruotger Skupin

Hi,

when comparing the class of two objects I usually do [obj1  
isKindOfClass:[obj2 class]]. But if I say have the Class as an input  
value to a method:


- (void) bla:(Class) inClass
{
if (/* inClass is an NSString */)
{
// do stuff
}
else if (/* inClass is an NSNumber */)
{
// do other stuff
}
}

Is it save to compare like this:

inClass == [NSString class]

or do I have to e.g.:

[[NSNumber numberWithInt:0] isKindOfClass:inClass]

Roddi

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: iPhoto thumbnail view

2008-10-15 Thread I. Savant

On Oct 15, 2008, at 5:35 AM, David Murphy wrote:


I'm looking to build a view, similar to the upper sequential thumbnail
view in iPhoto's Edit mode window.
Before I go and build my own version, does anyone know if this is
already available in an existing framework or library (from Apple or
elsewhere)?


  NSCollectionView. One row, n columns.

--
I.S.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Serial port over Bluetooth or not?

2008-10-15 Thread Daniel Kennett

Hey list,

I'm writing a framework that'll communicate with the Lego Mindstorms  
NXT brick [1] over a serial port, which is created either over  
Bluetooth or a USB connection (using the Bluetooth serial profile and  
a USB->Serial driver respectively).


The protocol dictates that messages sent over Bluetooth have an  
additional two bytes at the beginning of the message with a little  
endian UInt16 describing the length of the message.


I can construct this just fine using EndianU16_NtoL et. al, but what  
I'm struggling with is finding out if the serial port is a Bluetooth  
one or not. The serial port has a standard BSD path like /dev/tty.NXT.


Is there any way of finding out this information?

[1] http://mindstorms.lego.com/

 Thanks,

-- Daniel

 ___

   [EMAIL PROTECTED]
   http://www.kennettnet.co.uk

Please include previous messages in any reply you send.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: iPhoto thumbnail view

2008-10-15 Thread I. Savant

On Oct 15, 2008, at 8:02 AM, douglas welton wrote:

IKImageBrowserView is your friend.  Check out the example code  
ImageBrowser.  To constrain the view so that it only scrolls  
horizontally, use the -setContentResizingMask: method with the  
NSViewWidthSizable mask only.



  Ack! That's what I get for answering too quickly. I remembered  
playing with this control before (while exploring the new Interface  
Builder) but had totally forgotten about it. :-}


--
I.S.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Comparing the Class

2008-10-15 Thread Mike Abdullah


On 15 Oct 2008, at 14:20, Ruotger Skupin wrote:


Hi,

when comparing the class of two objects I usually do [obj1  
isKindOfClass:[obj2 class]]. But if I say have the Class as an input  
value to a method:


- (void) bla:(Class) inClass
{
if (/* inClass is an NSString */)
{
// do stuff
}
else if (/* inClass is an NSNumber */)
{
// do other stuff
}
}


You would do:

- (void)blah:(Class)inClass
{
if ([inClass isSubclassOfClass:[NSString class]])
{
// do stuff
}
etc.
}

Mike.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning

2008-10-15 Thread Michael Ash
On Wed, Oct 15, 2008 at 6:50 AM, Jonathan del Strother
<[EMAIL PROTECTED]> wrote:
> Presumably you could override +(id)alloc to be +(MyClass)alloc on
> classes that you knew implemented ambiguous init methods?

You could, but then every subclass of your class which defines its own
init methods is then forced to override +alloc as well. This is, of
course, the reason why +alloc and -init return id in the first place.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Providing replicable views in IB

2008-10-15 Thread Michael Ash
On Wed, Oct 15, 2008 at 9:05 AM, Matteo Manferdini
<[EMAIL PROTECTED]> wrote:
> Thank you very much!
> I did not think about the crappy way becase it *is* an unnatural way of
> doing things. By the way, how do you know NSCollectionView does it that way?
> Where do you collect such detailed informations?
> I did not know the second one. Thank you.

Starts with an educated guess from the fact that the view is in the
same nib as the rest, which precludes reloading the nib multiple
times. Process of elimination means that it must be using NSCoding. A
custom subclass which implements -initWithCoder: confirms it to be
true.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: iPhoto thumbnail view

2008-10-15 Thread douglas welton

Hi Dave,

IKImageBrowserView is your friend.  Check out the example code  
ImageBrowser.  To constrain the view so that it only scrolls  
horizontally, use the -setContentResizingMask: method with the  
NSViewWidthSizable mask only.


later,

douglas

On Oct 15, 2008, at 5:35 AM, David Murphy wrote:


hi folks,


I'm looking to build a view, similar to the upper sequential thumbnail
view in iPhoto's Edit mode window.
Before I go and build my own version, does anyone know if this is
already available in an existing framework or library (from Apple or
elsewhere)?


cheers


rgds Dave


___

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

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

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

This email sent to [EMAIL PROTECTED]


Decoding OSStatus values

2008-10-15 Thread Richard Dearlove
Is there an easy way to decode the values from OSStatus.  I have this  
#define that I copied from another project but it isnt really helping..


This gives me an error such as  Error: \316\377\377\377

#define checkStatus( err) \
if(err) {\
printf("Error: %s ->  %s: %d\n", (char *)&err,__FILE__, __LINE__);\
fflush(stdout);\
return err; \
}

cheers
RD

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Decoding OSStatus values

2008-10-15 Thread Jean-Daniel Dupas


Le 15 oct. 08 à 16:49, Richard Dearlove a écrit :

Is there an easy way to decode the values from OSStatus.  I have  
this #define that I copied from another project but it isnt really  
helping..


This gives me an error such as  Error: \316\377\377\377

#define checkStatus( err) \
if(err) {\
printf("Error: %s ->  %s: %d\n", (char *)&err,__FILE__, __LINE__);\
fflush(stdout);\
return err; \
}

cheers
RD


An OSStatus is not an OSType (FourCharCode).

OSStatus can be any value and does not generaly contains readable  
characters.


To get an idea about what an OSStatus represent, you can use thoses 2  
functions (from CarbonCore):


const char* GetMacOSStatusErrorString(OSStatus err);
const char* GetMacOSStatusCommentString(OSStatus err);


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Decoding OSStatus values

2008-10-15 Thread Richard D

Thanks!

On 15 Oct 2008, at 16:01, Jean-Daniel Dupas wrote:



Le 15 oct. 08 à 16:49, Richard Dearlove a écrit :

Is there an easy way to decode the values from OSStatus.  I have  
this #define that I copied from another project but it isnt really  
helping..


This gives me an error such as  Error: \316\377\377\377

#define checkStatus( err) \
if(err) {\
printf("Error: %s ->  %s: %d\n", (char *)&err,__FILE__, __LINE__);\
fflush(stdout);\
return err; \
}

cheers
RD


An OSStatus is not an OSType (FourCharCode).

OSStatus can be any value and does not generaly contains readable  
characters.


To get an idea about what an OSStatus represent, you can use thoses  
2 functions (from CarbonCore):


const char* GetMacOSStatusErrorString(OSStatus err);
const char* GetMacOSStatusCommentString(OSStatus err);




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread Steve Bird


On Oct 15, 2008, at 6:43 AM, han wrote:


how to complete a c/s app.Is there a sample code?


"c/s" =  ...
Computer Science?
Client / Server?
Cycles per Second?
C.S. Lewis?
Catch and Serve?
Cut and Scrape?
COBOL/SmallTalk?
Copy and Save?


Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175


___

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

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

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

This email sent to [EMAIL PROTECTED]


panelSelectionDidChange does not get called for items on the sidebar

2008-10-15 Thread Christos Konidaris

Just to save some other folk from wasting his time with this:

In my app delegate I've tried to implement the   
panel:panelSelectionDidChange  callback in order to customize our  
accessory view depending on the current user selection in the browser.  
Using the stripped down version below for investigating and following  
what NSLog outputs to the console I found out that my method is not  
called at all, when the user clicks any of the items under Devices or  
Places on the sidebar. It is called for items under the Media  
category, but all directory, filename and URL strings are null.


Code follows:

- (void) panelSelectionDidChange: (id) sender
{
NSLog( @"Selected directory: %@", [sender directory] );
NSLog( @"Selected filename: %@", [sender filename] );
NSLog( @"Selected URL: %@", [sender URL] );
}

Delegate method  panel:shouldShowFilename is called for the clicked  
item, so for our application we are going to cache the last selected  
item, and watch for changes ourselves (unless of course someone has a  
better solution to propose).


Submitted as bug:  rdar://6293537

Regards,

Christos Konidaris
Escape OE
___

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

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

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

This email sent to [EMAIL PROTECTED]


Fwd: how to complete c/s app

2008-10-15 Thread Benjamin Dobson

On 15 Oct 2008, at 16:21:48, Steve Bird wrote:



On Oct 15, 2008, at 6:43 AM, han wrote:


how to complete a c/s app.Is there a sample code?


"c/s" =  ...
Computer Science?
Client / Server?
Cycles per Second?
C.S. Lewis?
Catch and Serve?
Cut and Scrape?
COBOL/SmallTalk?
Copy and Save?



From the dictionary in OS X: cycles per second. Though that doesn't  
seem to make a lot more sense...


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Not so long filenames

2008-10-15 Thread Gerriet M. Denkmann


On 15 Oct 2008, at 03:32, Chris Suter wrote:


On Wed, Oct 15, 2008 at 7:00 AM, Gerriet M. Denkmann
<[EMAIL PROTECTED]> wrote:

So again my question: why it is too long in this context and where  
is this

documented?


This looks like a bug in the kernel code. It looks like it checks the
UTF8 string length against kHFSPlusMaxFileNameChars (rather than the
UTF-16 length).

You should report it.


I will, once I am sure that this bug is still in 10.5.

Kind regards,

Gerriet.

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSBezierPath problems, seems to be two bugs

2008-10-15 Thread Jochen Moeller

Hello List,

in the sample code Movie_Overlay (here with Xcode 3.1.1)

both subviews (AnimationView and ImageView) are filled with - 
whiteColor in -drawRect:.


- (void)drawRect:(NSRect)rect { // original AnimationView.m
  [[NSColor whiteColor] set];
  NSRectFill(rect);
  [self doStarAnimation];
}

This is not what I want because the movie is dimmed with increasing  
alpha values in the overlay. So I replaced the -whiteColor by - 
clearColor in both -drawRect: and used bounds instead of rect.  
Additionally I set the alpha value to 0.5 (instead 0.3) in MyDocument.


- (void)drawRect:(NSRect)rect { // 1st modification
  [[NSColor clearColor] set];   // in AnimationView.m
  NSRectFill([self bounds]);
  [self doStarAnimation];
}

1st Issue:
This worked fine in ImageView but in AnimationView remained a light  
grey shape of the animation figure which was not erased by  
NSRectFill(). Therefore I replaced NSRectFill() by -fillRect: in the  
next step.


- (void)drawRect:(NSRect)rect { // 2nd modification
  [[NSColor clearColor] set];   // in AnimationView.m
  [NSBezierPath fillRect:[self bounds]];
  [self doStarAnimation];
}

2nd Issue:
The remaining shape had gone but the movie was dimmed under the  
AnimationView. So -fillRect: seems not to be able to handle alpha  
values correct.

Next I tried to fill once with -whiteColor to erase the remaining shape.

- (void)drawRect:(NSRect)rect { // 3rd modification
  static int counter = 0;   // in AnimationView.m
  if ( counter == 0 ) {
[[NSColor whiteColor] set];
counter++ ;
  }
  else  [[NSColor clearColor] set];
  NSRectFill([self bounds]);
  [self doStarAnimation];
}

That almost worked. The shape had gone but a line between the views  
appeared.
I have the suspicion that the first call to NSBezierPath "stamps" the  
path in the background which is somewhere buffered and the rectangle  
is then always replaced by that buffer. So I tried a first call with  
an empty bezierpath object:


- (void)drawRect:(NSRect)rect { // 4th modification
  static int counter = 0;   // in AnimationView.m
  [[NSColor clearColor] set];
  NSRectFill([self bounds]);
  if ( counter == 0 ) {
NSBezierPath *bezierPath = [NSBezierPath bezierPath];
[bezierPath stroke]; // empty bezierpath
counter++;
  }
  else  [self doStarAnimation];
}

And that worked !! A clear underlaying movie.

So my questions. Are that known issues of NSBezierPath?
1. -fillRect: cannot handle alpha values correct,
2. The "stamp" in the background by the first call to NSBezierPath.

And is there another workaround, e.g. to clear the buffer which is  
used by NSRectFill() ?


Regards
Jochen Moeller

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: newbie question: tangential compiler errors

2008-10-15 Thread JB
I unchecked "Precompile Prefix Header" in the new target's build settings
(per Chris's comments) and it compiles without error now.

Thanks!
JB

On Mon, Oct 13, 2008 at 8:07 PM, Chris Hanson <[EMAIL PROTECTED]> wrote:

> On Oct 13, 2008, at 12:42 PM, JB wrote:
>
>  I've added Apple's sample LoginItemsAE class to autolaunch an app I've
>> built
>> for Tiger and Leopard.  However, the app fails to compile when I add
>> "LoginItemsAE.c" to the app target, throwing over 3000 "syntax" and
>> "conflicting types" errors here:
>>
>> AppKit.h > Foundation.h > NSObjCRuntime.h
>>
>
> You're probably doing this in a new target, which (due to limitations of
> how Xcode creates new targets from templates) has AppKit.h set as its prefix
> header.
>
> Using AppKit.h (which is Objective-C) as a prefix header doesn't guard
> against inclusion in plain C or C++ source files, unfortunately.  You'll
> have to switch the target's prefix header to a local prefix that includes an
> #ifdef __OBJC__/#endif around the #import of , one of which
> was probably created for you when you created the project.
>
>  -- Chris
>
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread han

han wrote:

how to complete a c/s app.Is there a sample code?


c/s = client/server. is there the sample codes download link


---han
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Providing replicable views in IB

2008-10-15 Thread Matteo Manferdini
Thank you very much!
I did not think about the crappy way becase it *is* an unnatural way of
doing things. By the way, how do you know NSCollectionView does it that way?
Where do you collect such detailed informations?
I did not know the second one. Thank you.
Cheers.

On Tue, Oct 14, 2008 at 5:56 PM, Michael Ash <[EMAIL PROTECTED]> wrote:

> On Tue, Oct 14, 2008 at 11:38 AM, Matteo Manferdini
> <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > I was trying to find a way to design a replicable view in IB.
> > The behaviour I'm trying to replicate is the one of NSCollectionView: it
> > gets a custom view designed in IB as the prototype view and then
> replicates
> > it to display its contents. Is there an easy way to do this? Since NSView
> > does not implement the copy method, I don't think this is the approach
> > taken.
> > The hard solution would be to provide a copy method myself that
> replicates
> > all the subviews and controls (which are also subviews), but it would be
> > very long and difficult since for each subview all the instance
> properties
> > must be replicated, without talking about sub-subviews. Since I don't
> want
> > to go throug all this, is there an easier way to do it?
> > Thank you very much.
> > Cheers.
>
> There are basically two ways to do it.
>
> One way, the crappy way, which NSCollectionView uses, is to use
> NSCoder. You'll note that NSView does not conform to NSCopying but it
> does conform to NSCoding. So the easy way to "copy" a view is to
> serialize and then deserialize it. This is crappy because it's kind of
> unnatural, requires some extra work to maintain external connections,
> and in general is just sort of clunky.
>
> The other way, which I prefer, is to simply put the view in question
> into a separate nib. Then just load the nib any time you want a new
> view.
>
> Mike
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/mat.mailings%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread Jason Coco


On Oct 15, 2008, at 12:05 , han wrote:


han wrote:

how to complete a c/s app.Is there a sample code?


c/s = client/server. is there the sample codes download link


That totally depends on the type of Client/Server app you want to  
make, what technologies you want to use to make it, etc.


You could probably get started here:

http://developer.apple.com/samplecode/Networking/index.html

Although you probably should have been able to find that yourself with  
just a tiny bit of looking...


J

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 [EMAIL PROTECTED]

gdb of va_alist?

2008-10-15 Thread David Springer
Folks,
I am looking into some legacy code that is called from a third-party
library.  The function being called has this signature:

AStringClass PlatformSpecificImplClass::formatMessage(unsigned int code,
va_list* argList)

The problem is that on x86 platforms, |argList| seems to point to a valid
4-byte unicode string "(null)", but on PPC, this string appears to be
garbled.  I say "appears to be" because I can't actually tell, since in
Xcode I have no visibility into |argList|.  Is there a way I can examine the
contents of this pointer?  I know the expected format of the memory, but I
don't know how to access it in gdb (or Xcode).  I am using Xcode 2.5, all
this code is built on a 10.5 box using g++.

Thanks!
- Dave.S
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -[NSGarbageCollection disableCollectorForPointer:] ?

2008-10-15 Thread Michael Link
That makes sense, although 'NSPointerFunctionsStrongMemory| 
NSPointerFunctionsOpaqueMemory' gives the error:


*** -[NSPointerArray initWithOptions:] Requested configuration not  
supported.


What I did try was 'NSPointerFunctionsStrongMemory| 
NSPointerFunctionsObjectPointerPersonality' which does work even  
though some of the pointers aren't objects and this doesn't seem quite  
correct but since I'm using GC  
NSPointerFunctionsObjectPointerPersonality seems nearly equivalent to  
NSPointerFunctionsOpaquePersonality as long as description isn't called.


--
Michael

On Oct 15, 2008, at 1:08 AM, Ken Ferry wrote:


Hi Michael,

NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory doesn't
make sense. You're meant to specify only one of the memory options and
only one of the personality options.

Due to the way the bitfield work, your invocation is the same as
NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality.
This is the mode in which the pointer array is completely hands-off.
It acts like a C array.

Try NSPointerFunctionsStrongMemory| 
NSPointerFunctionsOpaquePersonality.

That sounds right to me, though I get confused with the pointer
functions too.

-Ken

On Tue, Oct 14, 2008 at 9:43 PM, Michael Link <[EMAIL PROTECTED]>  
wrote:

I have a situation where I create an NSPointerArray on the stack by:

pointers = [NSPointerArray
pointerArrayWithOptions:NSPointerFunctionsStrongMemory| 
NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality];


I then go about adding a few objects a selector and a pointer  
(contextInfo

that could point to anything even a non-object) to the pointer array.

I then call:

[[NSGarbageCollector defaultCollector]  
disableCollectorForPointer:pointers];


The pointer array is then passed as the contextInfo for another  
method
(which turns out to be a weak reference), but isn't garbage  
collected due to
the previous call. The interesting part turns out that the object  
at index 0
(NSError* in this case) in the pointer array is garbage collected  
(probably
because it was a variable in the function that called us). The  
pointer array
is configured to use strong references therefore index 0 isn't set  
to NULL
and something else is located at that memory (sometimes a different  
object,

sometimes garbage memory).

If I use:

[[NSGarbageCollector defaultCollector] disableCollectorForPointer: 
[pointers

pointerAtIndex:0]];

nothing bad happens and that object isn't collected.

According to the documentation for disableCollectorForPointer:  
shouldn't the
pointer array be considered a new root object, and none of it's  
pointers

collected? Especially since it uses strong references?

--
Michael
___

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

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

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

This email sent to [EMAIL PROTECTED]






___

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

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

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

This email sent to [EMAIL PROTECTED]


Implementing a KVO/Bindings-Compliant Bridge-Pattern in Cocoa

2008-10-15 Thread Sebastian Morawietz
Hi folks,

I'm trying to implement a simple object bridge in cocoa where the
bridge object acts as a kvo/bindings-compliant drop in for some
arbitrary other NSObject-instance.

Here is my problem (more details in the attached code):

A Bridge object acts as a drop in for a Person-Object, with an
NSString* property called name and an Address* property address.
Binding to the keyPath "name" or "address" of the Bridge works nicely.
Trouble starts when binding some object to the keyPath
"address.street" of the bridge and a new Address-Object is set for
Person's address property. That results in KVO-related exceptions that
look like this:

* Cannot remove an observer  for the
key path "street"
* from  because it is not registered as an observer

This happens even though the bridge notices the change in the
"address"-Property and emits a
willChangeValueForKeyPath/didChangeValueForKeyPath tuple.

The attached code produces the the problem. The file contains a
main-function can be compiled and run with

* gcc -o test BridgeDemo.m -framework AppKit -framework Foundation; ./test

If you know a solution to this problem or can offer me a better
approach solving the same problem you make me a very happy programmer.

Greets
Seb


BridgeDemo.m
Description: Binary data
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: how to complete c/s app

2008-10-15 Thread Scott Ribe
> c/s = client/server. is there the sample codes download link

That is such a broad wide-open question as to be meaningless. There are at
least dozens of major design variations and hundreds of smaller ones
involved in client/server architecture. You're going to have get closer to
being able to describe what you want to do before you can realistically
expect effective help here.

-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

This email sent to [EMAIL PROTECTED]


NSFileBusy

2008-10-15 Thread Timothy Larkin
Is the NSFileBusy attribute returned by the NSFileManager set by the  
same conditions that cause a "file in use" error in the Finder? To put  
it another way, can I check whether deleting a file in the Finder will  
produce an "in use" error by looking at the state of the NSFileBusy  
flag?


--
Timothy Larkin
Abstract Tools
Caroline, NY

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Implementing a KVO/Bindings-Compliant Bridge-Pattern in Cocoa

2008-10-15 Thread Ken Thomases

On Oct 15, 2008, at 4:53 AM, Sebastian Morawietz wrote:


A Bridge object acts as a drop in for a Person-Object, with an
NSString* property called name and an Address* property address.
Binding to the keyPath "name" or "address" of the Bridge works nicely.
Trouble starts when binding some object to the keyPath
"address.street" of the bridge and a new Address-Object is set for
Person's address property. That results in KVO-related exceptions that
look like this:

* Cannot remove an observer  for the
key path "street"
* from  because it is not registered as an observer


On which line of testBindingToStreet() does the exception occur?  What  
is the stack trace?


I assume the Address object being mentioned in the exception is the  
new one created in -[Person modifyAddress].  Have you confirmed that?


One of the problems I noticed is in -[Bridge  
observeValueForKeyPath:...].  You are treating a key path as though it  
were a key.  will/didChangeValueForKey: don't take a key path; they  
treat whatever is passed as a key, even if it contains a period.   
(Note that there can be keys with embedded periods, like if a  
dictionary has keys like "com.example.foo" or "John Q. Public".)


More seriously, observeValueForKeyPath:... doesn't call through to  
super.  Your use of KVB is implicitly using KVO, plus you're also  
explicitly using KVO (from valueForUndefinedKey:).  Your  
observeValueForKeyPath:... only handles the latter.  Therefore, you're  
preventing the other observing code from coping with change  
notifications.


On top of that, I think there's a fundamental mismatch between will/ 
didChangeValueForKey: and observeValueForKeyPath:... that you can't  
account for.  It should be the case that willChangeValueForKey: is  
sent before the value changes and didChangeValueForKey: is sent  
afterward.  But observeValueForKeyPath:... is only invoked by KVO  
after both of those are sent.  You are turning around and trying to  
use will/didChangeValueForKey: within your observeValueForKeyPath:...   
You are pretending that the change is occurring during  
observeValueForKeyPath:... when it's really happened already.


KVO is trying to switch of which "address" it's watching the "street"  
property.  But it's being told to make this switch after the change  
has already occurred in the "obj" which Bridge holds.  Bridge's  
observeValueForKeyPath:... is invoked _after_ obj's address is done  
changing.  But during your explicit invocation of  
willChangeValueForKey:, KVO dutifully asks Bridge for the value of its  
"address" property in order to find out from which "address" it should  
unregister interest in the "street" property.  Bridge asks its "obj"  
and gets the new Address, not the old one.


In order to do what you're trying to do, you'd need some way to hook  
more directly into the will/didChangeValueForKey: machinery.  I don't  
know if it's possible.  Alternatively, Bridge will have to cache its  
own copy of each property of 'obj'.  It will be out of sync briefly  
with obj because Bridge will only be able to update its copy during  
observeValueForKeyPath:..., but this is actually exactly what you need  
to fix the problem.  You would issue the willChangeValueForKey: call  
before updating Bridge's copy, update the copy, then invoke  
didChangeValueForKey: afterward.  KVO would then have access to the  
old address so it can unregister itself properly.


This is a hard problem.  Also, I'm not really sure why you're  
attempting to do what you're doing.  The dynamism of KVC/KVO should  
allow you to achieve your ends without the Bridge pattern.  After all,  
your bridge implementation requires that the wrapped object is already  
KVC/KVO-compliant for the keys being accessed.  So, I'm not sure what  
you're hoping to gain.  Can you explain what you need this for?



As an aside, here are a couple of nit-picks about the code:

* On 10.5 and later, you can use -forwardingTargetForSelector: for  
simpler and faster forwarding.  It's only documented (so far) in the  
Leopard release notes .


* Bridge's observedKeys should probably be a NSMutableSet rather than  
an NSMutableDictionary, since you only care about the presence or  
absence of keys and never about values.



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 [EMAIL PROTECTED]


Building smart folder list as in iTunes

2008-10-15 Thread Jushin
I would like to add a left pane (I don't know what to call this) as in
iTunes or Apple Mail.
In this pane, I want make place a library, folders, and smart folders.
Where should I start?
I couldn't find any example code or documentation regarding this.
Please someone help me how to do this.

Thanks,
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Building smart folder list as in iTunes

2008-10-15 Thread Steven Riggs

This should get you in the right direction..

http://developer.apple.com/samplecode/SourceView/index.html

-Steve

On Oct 15, 2008, at 12:59 PM, Jushin wrote:


I would like to add a left pane (I don't know what to call this) as in
iTunes or Apple Mail.
In this pane, I want make place a library, folders, and smart folders.
Where should I start?
I couldn't find any example code or documentation regarding this.
Please someone help me how to do this.

Thanks,
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/steven.riggs%40me.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning

2008-10-15 Thread Chris Suter
On Wed, Oct 15, 2008 at 9:03 PM, John Engelhart
<[EMAIL PROTECTED]> wrote:
>
> On Oct 14, 2008, at 7:11 AM, Chris Suter wrote:
>>
>> You can't override the type for existing methods. For example,
>> initWithString: always returns an id. You can define them as returning
>> something different but the compiler will ignore it.
>
> Just a clarification on this particular point- it is possible to override
> the type(s) of existing methods, both the argument and return types.

You're quite right.

What I meant to point out was that you can't easily override init
methods because of the problem with alloc returning id. That was
something I came across a while back which was why I got the details
slightly wrong. :-)

Sorry for any confusion caused.

-- Chris
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTask not cleaning up it's threads

2008-10-15 Thread Ken Thomases

On Oct 15, 2008, at 3:25 AM, C. Tearpak wrote:


Thanks for your insight, Ken.


You're welcome.

It's very possible that you are right, though I haven't tried your  
suggestions, especially since you are mentioning the "wait" parameter.


Sorry, I didn't mean to be confusing.  The - 
performSelectorOnMainThread:withObject:waitUntilDone: method of  
NSObject takes as its last argument a "wait" parameter.  If it's YES  
(or TRUE, etc.) then the caller is blocked until the main thread has  
completed performing the selector.  The request to perform a selector  
on the main thread is carried out through the run loop mechanism.  If  
the main thread's run loop isn't running, then the caller of  
performSelectorOnMainThread:withObject:waitUntilDone: won't ever  
proceed and that thread will never get around to exiting.



I am normally a C# / .NET programmer by day, with other experience  
in Java, so the RunLoop and Timer are still somewhat foreign  
concepts to me, and when looking at threading, having control via  
the NSThread is more familiar and less weird to me. Hopefully, that  
will change, as I have seen APIs that require doing work via  
RunLoops and I have run in to issues when an NSThread created by me  
needs to interact with one.


I seem to have solved the problem. It seems like, after some  
tinkering, adding a [task waitUntilExit]; before exiting the  
runCommand method fixes the thread leak.


-waitUntilExit is documented to run the run loop.  Doing things this  
way, though, precludes running multiple tasks simultaneously.



I suppose  it could be the fact that NSTask is "creating a separate  
executable entity" per the NSTask documentation, and that, even  
though it does not share memory space with my process, it would need  
to communicate via the pipe that was configured for stdout. If the  
objects created in that method were cleaned up and it could no  
longer communicate via the pipe or whatever, it might just leak and  
not know how or when to terminate itself That's what it seems  
like, anyhow.


It is my impression that various asynchronous APIs in Cocoa use  
background threads to carry out some operations synchronously and then  
use something like - 
performSelectorOnMainThread:withObject:waitUntilDone: to call delegate  
methods or post notifications on the main thread.  This may apply to  
NSTask and the way it monitors the task it launches, and to  
NSFileHandle in the way it performs I/O.


I don't think it has anything to do with the actual process management  
going on within NSTask.  That is, neither forking a child process nor  
holding or reading a pipe necessarily requires the creation of a  
thread nor keeping it alive.  This is also not a memory management or  
garbage collection issue.


However, this is just a guess and nobody should really count on such  
internal implementation details.  I know it's frustrating not to know  
all the nitty-gritty details of what's going on.  However, you just  
have to accept that some of the framework classes will expect and  
require that the run loop will be run.


Framework and API designers often hide implementation details.  This  
is for your protection and for their benefit.  It protects you because  
if you don't know the implementation details you can't build code  
which relies on them.  Then, your code doesn't break when they decide  
to change the implementation.  It benefits them because they have the  
flexibility to change the implementation details to enable new  
features for the framework.



If anyone has any insight as to the actual reason that this would be  
happen and could shed light, I would definitely like to know what is  
actually going on to gain a better understanding of the underlying  
APIs and their interactions with executables and the environment.


Did you try my suggestion?


On Oct 14, 2008, at 10:46 PM, Ken Thomases wrote:

You can use Activity Monitor's Sample Process feature to get a  
sense of what the extraneous threads are stuck waiting for.


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 [EMAIL PROTECTED]


Re: NSBezierPath problems, seems to be two bugs

2008-10-15 Thread Aki Inoue

Jochen,

The behavioral differences you're observing is the result of  
NSCompositingOperation setting.


NSRectFill() uses NSCompositeCopy whereas NSBezierPath does not modify  
the current setting that is accessible via -[NSGraphicsContext  
compositingOperation].


Aki

On 2008/10/15, at 4:56, Jochen Moeller wrote:


Hello List,

in the sample code Movie_Overlay (here with Xcode 3.1.1)

both subviews (AnimationView and ImageView) are filled with - 
whiteColor in -drawRect:.


- (void)drawRect:(NSRect)rect { // original AnimationView.m
 [[NSColor whiteColor] set];
 NSRectFill(rect);
 [self doStarAnimation];
}

This is not what I want because the movie is dimmed with increasing  
alpha values in the overlay. So I replaced the -whiteColor by - 
clearColor in both -drawRect: and used bounds instead of rect.  
Additionally I set the alpha value to 0.5 (instead 0.3) in MyDocument.


- (void)drawRect:(NSRect)rect { // 1st modification
 [[NSColor clearColor] set];   // in AnimationView.m
 NSRectFill([self bounds]);
 [self doStarAnimation];
}

1st Issue:
This worked fine in ImageView but in AnimationView remained a light  
grey shape of the animation figure which was not erased by  
NSRectFill(). Therefore I replaced NSRectFill() by -fillRect: in the  
next step.


- (void)drawRect:(NSRect)rect { // 2nd modification
 [[NSColor clearColor] set];   // in AnimationView.m
 [NSBezierPath fillRect:[self bounds]];
 [self doStarAnimation];
}

2nd Issue:
The remaining shape had gone but the movie was dimmed under the  
AnimationView. So -fillRect: seems not to be able to handle alpha  
values correct.
Next I tried to fill once with -whiteColor to erase the remaining  
shape.


- (void)drawRect:(NSRect)rect { // 3rd modification
 static int counter = 0;   // in AnimationView.m
 if ( counter == 0 ) {
   [[NSColor whiteColor] set];
   counter++ ;
 }
 else  [[NSColor clearColor] set];
 NSRectFill([self bounds]);
 [self doStarAnimation];
}

That almost worked. The shape had gone but a line between the views  
appeared.
I have the suspicion that the first call to NSBezierPath "stamps"  
the path in the background which is somewhere buffered and the  
rectangle is then always replaced by that buffer. So I tried a first  
call with an empty bezierpath object:


- (void)drawRect:(NSRect)rect { // 4th modification
 static int counter = 0;   // in AnimationView.m
 [[NSColor clearColor] set];
 NSRectFill([self bounds]);
 if ( counter == 0 ) {
   NSBezierPath *bezierPath = [NSBezierPath bezierPath];
   [bezierPath stroke]; // empty bezierpath
   counter++;
 }
 else  [self doStarAnimation];
}

And that worked !! A clear underlaying movie.

So my questions. Are that known issues of NSBezierPath?
1. -fillRect: cannot handle alpha values correct,
2. The "stamp" in the background by the first call to NSBezierPath.

And is there another workaround, e.g. to clear the buffer which is  
used by NSRectFill() ?


Regards
Jochen Moeller

___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning

2008-10-15 Thread Jonathan del Strother
On Wed, Oct 15, 2008 at 11:36 AM, Chris Suter <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 15, 2008 at 9:03 PM, John Engelhart
> <[EMAIL PROTECTED]> wrote:
>>
>> On Oct 14, 2008, at 7:11 AM, Chris Suter wrote:
>>>
>>> You can't override the type for existing methods. For example,
>>> initWithString: always returns an id. You can define them as returning
>>> something different but the compiler will ignore it.
>>
>> Just a clarification on this particular point- it is possible to override
>> the type(s) of existing methods, both the argument and return types.
>
> You're quite right.
>
> What I meant to point out was that you can't easily override init
> methods because of the problem with alloc returning id. That was
> something I came across a while back which was why I got the details
> slightly wrong. :-)
>

Presumably you could override +(id)alloc to be +(MyClass)alloc on
classes that you knew implemented ambiguous init methods?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread Graham Cox


On 15 Oct 2008, at 9:43 pm, han wrote:


how to complete a c/s app.Is there a sample code?



Who knows. Maybe you could start by explaining what a c/s app is?


--G
___

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

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

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

This email sent to [EMAIL PROTECTED]


how to complete c/s app

2008-10-15 Thread han

how to complete a c/s app.Is there a sample code?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: executables for OSX 10.4 vs 10.5

2008-10-15 Thread Thomas Engelmeier


Am 15.10.2008 um 02:10 schrieb Michael Williamson:

Or is there some way to build a single app that runs on both and if  
so are there any drawbacks to doing this?


The only drawback is you get partially buggy, backward compatible  
behavior on Leopard when you link against the 10.4 SDK.




___

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

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

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

This email sent to [EMAIL PROTECTED]


iPhoto thumbnail view

2008-10-15 Thread David Murphy

hi folks,


I'm looking to build a view, similar to the upper sequential thumbnail
view in iPhoto's Edit mode window.
Before I go and build my own version, does anyone know if this is
already available in an existing framework or library (from Apple or
elsewhere)?


cheers


rgds Dave


__
David Murphy

Department of Computer Science
University College Cork
Ireland

p: 00353 (0)21 4903579
f:  00353 (0)21 4274390
e: [EMAIL PROTECTED]
w: http://multimedia.ucc.ie
w: http://www.cs.ucc.ie/staff/dmurphy.html
blog: http://vrplace.blogspot.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 [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread Andrew Merenbach

On Oct 15, 2008, at 4:00 AM, Graham Cox wrote:



On 15 Oct 2008, at 9:43 pm, han wrote:


how to complete a c/s app.Is there a sample code?



Who knows. Maybe you could start by explaining what a c/s app is?


--G


Perhaps "c/s" stands for "client/server," but I've no idea.

-- Andrew

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 [EMAIL PROTECTED]

Re: Decoding OSStatus values

2008-10-15 Thread Peter Ammon


On Oct 15, 2008, at 7:49 AM, Richard Dearlove wrote:

Is there an easy way to decode the values from OSStatus.  I have  
this #define that I copied from another project but it isnt really  
helping..


This gives me an error such as  Error: \316\377\377\377

#define checkStatus( err) \
if(err) {\
printf("Error: %s ->  %s: %d\n", (char *)&err,__FILE__, __LINE__);\
fflush(stdout);\
return err; \
}

cheers
RD


Also see this:

open -h MacErrors.h

-Peter

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Decoding OSStatus values

2008-10-15 Thread Randall Meadows

On Oct 15, 2008, at 1:22 PM, Peter Ammon wrote:


On Oct 15, 2008, at 7:49 AM, Richard Dearlove wrote:

Is there an easy way to decode the values from OSStatus.  I have  
this #define that I copied from another project but it isnt really  
helping..


This gives me an error such as  Error: \316\377\377\377

#define checkStatus( err) \
if(err) {\
printf("Error: %s ->  %s: %d\n", (char *)&err,__FILE__, __LINE__);\
fflush(stdout);\
return err; \
}

cheers
RD


Also see this:

open -h MacErrors.h


As well as /usr/bin/macerror ('man macerror').
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: gdb of va_alist?

2008-10-15 Thread Andrew Farmer

On 15 Oct 08, at 09:23, David Springer wrote:

Folks,
I am looking into some legacy code that is called from a third-party
library.  The function being called has this signature:

AStringClass PlatformSpecificImplClass::formatMessage(unsigned int  
code,

va_list* argList)

The problem is that on x86 platforms, |argList| seems to point to a  
valid

4-byte unicode string "(null)", but on PPC, this string appears to be
garbled.  I say "appears to be" because I can't actually tell, since  
in
Xcode I have no visibility into |argList|.  Is there a way I can  
examine the

contents of this pointer?


va_list is generally treated as an opaque type (it's defined in  
stdarg.h). If you know exactly how it's laid out, you can try  
something like


(gdb) x/4x argList

but don't assume anything about its layout outside a debugging context.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Multiple persistent store coordinators gotchas?

2008-10-15 Thread Dave Dribin

Hello,

I'm working on a Core Data application that does lots of processing of  
the data in background threads to generate reports.  I'd like to  
investigate using multiple persistent store coordinators to reduce  
lock contention, i.e. pattern #2, as described in the multi-threaded  
chapter of the Core Data guide.


I'm thinking it is a good fit in this case as the background threads  
are doing mainly read-only operations on the data.  It does modify  
transient properties, but I think I can still get away with using a  
read-only store on the background threads.  Is this correct?


The documentation is a little thin about using multiple PSCs.  Is it  
just a matter of setting up separate Core Data stacks per thread?   
What are the downsides, especially compared to 1 PSC/multiple MOCs?   
Higher memory usage?  Separate caches?  Stale data?  Anything else to  
watch out for?


Thanks,

-Dave

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTokenField: Tokenizing on Right Arrow key

2008-10-15 Thread Dirk Musfeldt
Hi,

I'm using NSTokenField on 10.5. I want the field to display the token once
the user presses the right arrow key to get at the end of the selection.
this is the way it works in Mail's address field.

Unfortunately this does not work as expected. It works if the user enters
one of the tokenizing characters or presses the return key but not with the
right arrow key.

Anybody has a suggestion how to get that working?


Regards

Dirk



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning

2008-10-15 Thread John Engelhart


On Oct 14, 2008, at 7:11 AM, Chris Suter wrote:


You can't override the type for existing methods. For example,
initWithString: always returns an id. You can define them as returning
something different but the compiler will ignore it.


Just a clarification on this particular point- it is possible to  
override the type(s) of existing methods, both the argument and return  
types.  The following snippet of code demonstrates this.  The return  
types were specifically chosen because the ABI specifies that each  
result is returned in a different way from the other (i.e., the double  
is returned via a floating point register, at least on ppc).


#import 

@interface MYTest: NSObject -(int)result; @end
@interface MYMutableTest : MYTest   -(double) result; @end
@interface MYOtherTest   : NSObject -(NSRange)result; @end

@implementation MYTest-(int)result  
{ return(23);   }   @end
@implementation MYMutableTest -(double) result  
{ return(42.0); }   @end
@implementation MYOtherTest   -(NSRange)result  
{ return(NSMakeRange(23,42)); } @end


int main(int argc, char *argv[]) {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

  MYTest*myTest= [[[MYTestalloc] init]  
autorelease];
  MYMutableTest *myMutableTest = [[[MYMutableTest alloc] init]  
autorelease];
  MYOtherTest   *myOtherTest   = [[[MYOtherTest   alloc] init]  
autorelease];


  NSLog(@"myTest   : %d", [myTest result]);
  NSLog(@"myMutableTest: %f", [myMutableTest result]);
  NSLog(@"myOtherTest  : %@", NSStringFromRange([myOtherTest result]));

  return(0);
}

shell% gcc -o typeTest typeTest.m -framework Foundation
[No warnings or errors]
shell% ./typeTest
2008-10-15 05:34:48.566 typeTest[7494:807] myTest   : 23
2008-10-15 05:34:48.625 typeTest[7494:807] myMutableTest: 42.00
2008-10-15 05:34:48.645 typeTest[7494:807] myOtherTest  : {23, 42}

This demonstrates that the correct return type was chosen at compile  
time because each result type is returned in a unique and different  
way,  If the compiler didn't get the return type correct, the results  
would be random garbage.  The compiler can do this because the class  
is statically typed.  If the class isn't known (i.e., id), then things  
don't work quite so well, especially in the example above.  Trying to  
get a floating point double result out of a general purpose int  
register usually doesn't work.  :)


___

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

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

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

This email sent to [EMAIL PROTECTED]


NSView subclass

2008-10-15 Thread DKJ
I've written a subclass of NSView. It calls a method its delegate can  
implement to detect mouse clicks. I've put something like this in the  
header file:


// delegate method:
@interface NSObject ()
- (void)pointClicked:(NSPoint)point;
@end

This is enough to prevent a "no -pointClicked: method found" compiler  
warning. But is it the best way to do it?


dkj
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSView subclass

2008-10-15 Thread Scott Andrew
If its a delegate you would want to check if the delegate handles the  
selector with respondsToSelector and the use performSelector to make  
the call. For example


if ([delegate respondsToSelector:@selector(pointClicked:)])
	[delegate performSelector:@selector(pointClicked:) withObject: 
[NSValue valueWithPoint:(pt)]];


This should work. I believe the NSValue will resolve to the NSPoint in  
runtime.


Scott Andrew


On Oct 15, 2008, at 2:15 PM, DKJ wrote:

I've written a subclass of NSView. It calls a method its delegate  
can implement to detect mouse clicks. I've put something like this  
in the header file:


// delegate method:
@interface NSObject ()
- (void)pointClicked:(NSPoint)point;
@end

This is enough to prevent a "no -pointClicked: method found"  
compiler warning. But is it the best way to do it?


dkj
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSView subclass

2008-10-15 Thread Mike Abdullah

You should really name your category. Something like:

@interface NSObject (MyViewDelegate)

Even better if you're targeting Leopard only is to use a formal  
protocol, but with optional methods. e.g.


@protocol MyViewDelegate
@optional
- (void)pointClicked:(NSPoint)point;
@end

On 15 Oct 2008, at 22:15, DKJ wrote:

I've written a subclass of NSView. It calls a method its delegate  
can implement to detect mouse clicks. I've put something like this  
in the header file:


// delegate method:
@interface NSObject ()
- (void)pointClicked:(NSPoint)point;
@end

This is enough to prevent a "no -pointClicked: method found"  
compiler warning. But is it the best way to do it?


dkj
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSView subclass

2008-10-15 Thread Jonathan Hess


On Oct 15, 2008, at 2:30 PM, Scott Andrew wrote:

If its a delegate you would want to check if the delegate handles  
the selector with respondsToSelector and the use performSelector to  
make the call. For example


if ([delegate respondsToSelector:@selector(pointClicked:)])
	[delegate performSelector:@selector(pointClicked:) withObject: 
[NSValue valueWithPoint:(pt)]];


NSValue is a normal class just like any other class. KVO, and KVC  
happen to use NSValue to box and unbox non object types. If you pass a  
function or method an NSValue, it will receive an NSValue. Methods  
like setValue:forKey: actually receive an NSValue object, but then  
manually unbox the value before calling the methods indicated by the  
second key argument.


Since you've declared your delegate method in a header, you can call  
it directly. This eliminates the need for performSelector:withObject:,  
which is probably what caused Scott to try to use NSValue.


You can now write:

if ([delegate respondsToSelector:@selector(pointClicked:)]) {
[delegate pointClicked:pt];
}

Also, instead of this:

@interface NSObject ()
- (void)pointClicked:(NSPoint)point;
@end

You should write

@interface NSObject (MyViewSubclassDelegation)
- (void)pointClicked:(NSPoint)point;
@end

Having the category name is more descriptive. Also, having an empty  
category name is a special form and means you're using a class  
extension. You can read about those here: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_5.html#/ 
/apple_ref/doc/uid/TP30001163-CH20-SW2


Good Luck -
Jon Hess




This should work. I believe the NSValue will resolve to the NSPoint  
in runtime.


Scott Andrew


On Oct 15, 2008, at 2:15 PM, DKJ wrote:

I've written a subclass of NSView. It calls a method its delegate  
can implement to detect mouse clicks. I've put something like this  
in the header file:


// delegate method:
@interface NSObject ()
- (void)pointClicked:(NSPoint)point;
@end

This is enough to prevent a "no -pointClicked: method found"  
compiler warning. But is it the best way to do it?


dkj
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Comparing the Class

2008-10-15 Thread Melissa J. Turner


On Oct 15, 2008, at 06:20, Ruotger Skupin wrote:


Hi,

when comparing the class of two objects I usually do [obj1  
isKindOfClass:[obj2 class]]. But if I say have the Class as an input  
value to a method:


- (void) bla:(Class) inClass
{
if (/* inClass is an NSString */)
{
// do stuff
}
else if (/* inClass is an NSNumber */)
{
// do other stuff
}
}

Is it save to compare like this:

inClass == [NSString class]

or do I have to e.g.:

[[NSNumber numberWithInt:0] isKindOfClass:inClass]



It's generally unwise to do this kind of thing if you're dealing with  
class clusters or bridged classes (which category includes both  
NSString and NSNumber). The class you actually get may not be what  
you're expecting.


If you're doing it with your own classes, it's safer, but can be  
fragile, since it's one more thing you're going to need to remember to  
change if you change your inheritance hierarchy.


+Melissa

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Targetting 10.4

2008-10-15 Thread Kevin Bracey

Hi

Don't forget that the 10.4 sdk, is named MacOSX10.4u

Cheers
Kevin
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSView subclass

2008-10-15 Thread DKJ

Now another problem! When I put this in the MyViewSubclass header:


@interface NSObject (MyViewSubclassDelegation)
- (void)pointClicked:(NSPoint)point;
@end


I get an XCode internal error:

Uncaught Exception:
*** -[NSCFString substringWithRange:]: Range or index out of bounds

It was actually preventing me from typing the category name: I had to  
type the name first, and put the parentheses around after.


The error message appears whenever I click inside the category name  
parentheses. But I can click "continue" and then build without any  
trouble.


What could be causing this? Has it something to do with code completion?

dkj
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Multiple persistent store coordinators gotchas?

2008-10-15 Thread Melissa J. Turner


On Oct 15, 2008, at 14:00, Dave Dribin wrote:


Hello,

I'm working on a Core Data application that does lots of processing  
of the data in background threads to generate reports.  I'd like to  
investigate using multiple persistent store coordinators to reduce  
lock contention, i.e. pattern #2, as described in the multi-threaded  
chapter of the Core Data guide.


I'm thinking it is a good fit in this case as the background threads  
are doing mainly read-only operations on the data.  It does modify  
transient properties, but I think I can still get away with using a  
read-only store on the background threads.  Is this correct?




If your second thread is doing pure report generation, and whatever  
transients it sets won't affect anything outside the report  
generation, this is the solution you're looking for.


The documentation is a little thin about using multiple PSCs.  Is it  
just a matter of setting up separate Core Data stacks per thread?


Yes.

What are the downsides, especially compared to 1 PSC/multiple MOCs?   
Higher memory usage?  Separate caches?  Stale data?  Anything else  
to watch out for?




The downside tends to be more memory use, since you'll have two copies  
of all the data for each object that is loaded into both stacks in  
addition to the overhead of the stack itself. Stale data is unlikely  
to be a problem unless you're expecting to load it significantly  
before you actually need it, which would be the same if you were  
loading it into a separate context on the same coordinator.


The big upside is that it decreases the amount of time your UI thread  
will be blocked on reads being done by the background thread.


+Melissa




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -[NSGarbageCollection disableCollectorForPointer:] ?

2008-10-15 Thread Ken Ferry
> What I did try was
>
'NSPointerFunctionsStrongMemory|NSPointerFunctionsObjectPointerPersonality'
> which does work even though some of the pointers aren't objects and this
> doesn't seem quite correct but since I'm using GC
> NSPointerFunctionsObjectPointerPersonality seems nearly equivalent to
> NSPointerFunctionsOpaquePersonality as long as description isn't called.

I see.. I think it's a bug that
NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory
is rejected.

It's probably not very future safe to add non-objects with the object
personality.  You might prefer to use NSAllocateCollectable(NSScannedOption)
and forego the pointer array.  This allocates a chunk of memory that is:

(1) Collected by the collector when unreachable by strong reference chain
from a gc-root.
(2) Conservatively scanned.

To keep the memory alive when used as the void* contextInfo, you'd still
need to use -[NSGarbageCollector disableCollectorForPointer:].

The main gotcha is that any stores of gc objects into the buffer need to
generate write barriers, which are calls into the objective-c library that
let the collector know that the the buffer has changed and needs to be
rescanned next time a collection runs.  This should Just Work provided the
type of the buffer is __strong, but you can put doubt to rest by checking
that the compiler emitted the function calls.  In Xcode, right click and
choose "Show Assembly Code", then look for the calls.  For example, this

- (void)writeToCollectableMemory:(NSObject *)object {

int bufferLength = 5;

__strong void **buffer = (__strong void**)NSAllocateCollectable(sizeof(
void*)*bufferLength, NSScannedOption);

buffer[3] = [[NSObject alloc] init];
…

compiles to this.  objc_assign_strongCast is the function call.

"-[MyBlockOperation writeToCollectableMemory:]":

LFB672:

LM221:

LVL93:

pushl %ebp

LCFI337:

movl %esp, %ebp

LCFI338:

pushl %esi

LCFI339:

pushl %ebx

LCFI340:

subl $16, %esp

LCFI341:

call L245

"L076$pb":

L245:

popl %ebx

LM222:

movl $1, 4(%esp)

movl $20, (%esp)

call _NSAllocateCollectable

movl %eax, %esi

LM223:

movl L_OBJC_SELECTOR_REFERENCES_3-"L076$pb"(%ebx), %eax

movl %eax, 4(%esp)

movl L_OBJC_CLASS_REFERENCES_0-"L076$pb"(%ebx), %eax

movl %eax, (%esp)

call _objc_msgSend

movl L_OBJC_SELECTOR_REFERENCES_4-"L076$pb"(%ebx), %edx

movl %edx, 4(%esp)

movl %eax, (%esp)

call _objc_msgSend

leal 12(%esi), %edx

movl %edx, 4(%esp)

movl %eax, (%esp)

call *_objc_assign_strongCast*
…

-Ken
Cocoa Frameworks

On Wed, Oct 15, 2008 at 9:32 AM, Michael Link <[EMAIL PROTECTED]> wrote:
> That makes sense, although
> 'NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory' gives the
> error:
>
> *** -[NSPointerArray initWithOptions:] Requested configuration not
> supported.
>
> What I did try was
>
'NSPointerFunctionsStrongMemory|NSPointerFunctionsObjectPointerPersonality'
> which does work even though some of the pointers aren't objects and this
> doesn't seem quite correct but since I'm using GC
> NSPointerFunctionsObjectPointerPersonality seems nearly equivalent to
> NSPointerFunctionsOpaquePersonality as long as description isn't called.
>
> --
> Michael
>
> On Oct 15, 2008, at 1:08 AM, Ken Ferry wrote:
>
>> Hi Michael,
>>
>> NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory doesn't
>> make sense. You're meant to specify only one of the memory options and
>> only one of the personality options.
>>
>> Due to the way the bitfield work, your invocation is the same as
>> NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality.
>> This is the mode in which the pointer array is completely hands-off.
>> It acts like a C array.
>>
>> Try NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaquePersonality.
>> That sounds right to me, though I get confused with the pointer
>> functions too.
>>
>> -Ken
>>
>> On Tue, Oct 14, 2008 at 9:43 PM, Michael Link <[EMAIL PROTECTED]> wrote:
>>>
>>> I have a situation where I create an NSPointerArray on the stack by:
>>>
>>> pointers = [NSPointerArray
>>>
>>>
pointerArrayWithOptions:NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality];
>>>
>>> I then go about adding a few objects a selector and a pointer
>>> (contextInfo
>>> that could point to anything even a non-object) to the pointer array.
>>>
>>> I then call:
>>>
>>> [[NSGarbageCollector defaultCollector]
>>> disableCollectorForPointer:pointers];
>>>
>>> The pointer array is then passed as the contextInfo for another method
>>> (which turns out to be a weak reference), but isn't garbage collected
due
>>> to
>>> the previous call. The interesting part turns out that the object at
>>> index 0
>>> (NSError* in this case) in the pointer array is garbage collected
>>> (probably
>>> because it was a variable in the function that called us). The pointer
>>> array
>>> is configured to use strong references therefore index 0 isn't set to
>>> NULL
>>> and somethin

-[NSMutableSet addObject:] Ambiguous Docs: -isEqual: vs. ==

2008-10-15 Thread Jerry Krinock

Documentation for -[NSMutableSet addObject:] says:

"Adds a given object to the receiver, if it is not already a  
member.  ...  If anObject is already present in the set, this method  
has no effect on either the set or anObject."


The terms "a member" and "present" are not defined and there are two  
possible meanings in the Cocoa context: "-isEqual:" or " == ".


My first guess was that it meant " == " but I did a test [1] and found  
that I was wrong.  My test result showed the behavior to be that of "- 
isEqual:".


I am assuming therefore assuming "-isEqual:" in writing my code.   
Someone please let me know if they see any risk in that.


Yes, I've sent feedback to Apple about the imprecise documentation.

Jerry Krinock


[1]

#import 

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSMutableSet* ms = [NSMutableSet set] ;

// Produce two strings that are "-isEqual"
// but not == .
NSInteger r1 = random() ;
NSInteger r2 = random() ;
NSInteger rr1 = r1/2048 + r2/2048 ;
NSInteger rr2 = r1/2048 + r2/2048 ;
NSString* s1 = [NSString stringWithFormat:@"%d", rr1] ;
NSString* s2 = [NSString stringWithFormat:@"%d", rr2] ;
NSLog(@"s1: %p %@", s1, s1) ;
NSLog(@"s2: %p %@", s2, s2) ;
// Unless the compiler is REALLY smart, it does not
// know that s1 and s2 are "-isEqual", without in
// fact invoking -isEqual.

// Now add both of them to as set
[ms addObject:s1] ;
[ms addObject:s2] ;
NSLog([ms describeInDetail]) ;
[ms removeAllObjects] ;

[pool drain] ;
return 0;
}

@interface NSSet (DetailDescription)

- (NSString*)describeInDetail ;


@end

@implementation NSSet (DetailDescription)

- (NSString*)describeInDetail {
NSMutableString* dd = [NSMutableString string] ;
[dd appendFormat:@"Set has %d objects:", [self count]] ;
for (id s in self) {
[dd appendFormat:@"   %p %@", s, s] ;
}

return dd ;
}

@end

** OUTPUT **

s1: 0x1067b0 1294540
s2: 0x107180 1294540
Set has 1 objects:   0x1067b0 1294540


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSBezierPath problems, seems to be two bugs

2008-10-15 Thread Jochen Moeller

Hi Aki,

thanks a lot for the valuable info which was new to me.

With setting NSCompositeCopy of the current context I could exactly  
reproduce the feature of NSRectFill() with -fillRect:.
This means that also the light grey shape still remains during the  
animation which was the reason for me to try -fillRect:  ;-)


So one issue is solved, maybe the other will follow?

Thanks again,
Jochen Moeller


On 15.10.2008, at 19:21, Aki Inoue wrote:


Jochen,

The behavioral differences you're observing is the result of  
NSCompositingOperation setting.


NSRectFill() uses NSCompositeCopy whereas NSBezierPath does not  
modify the current setting that is accessible via - 
[NSGraphicsContext compositingOperation].


Aki

On 2008/10/15, at 4:56, Jochen Moeller wrote:


Hello List,

in the sample code Movie_Overlay (here with Xcode 3.1.1)

both subviews (AnimationView and ImageView) are filled with - 
whiteColor in -drawRect:.


- (void)drawRect:(NSRect)rect { // original AnimationView.m
[[NSColor whiteColor] set];
NSRectFill(rect);
[self doStarAnimation];
}

This is not what I want because the movie is dimmed with increasing  
alpha values in the overlay. So I replaced the -whiteColor by - 
clearColor in both -drawRect: and used bounds instead of rect.  
Additionally I set the alpha value to 0.5 (instead 0.3) in  
MyDocument.


- (void)drawRect:(NSRect)rect { // 1st modification
[[NSColor clearColor] set];   // in AnimationView.m
NSRectFill([self bounds]);
[self doStarAnimation];
}

1st Issue:
This worked fine in ImageView but in AnimationView remained a light  
grey shape of the animation figure which was not erased by  
NSRectFill().

...

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -[NSMutableSet addObject:] Ambiguous Docs: -isEqual: vs. ==

2008-10-15 Thread Nick Zitzmann


On Oct 15, 2008, at 5:45 PM, Jerry Krinock wrote:

I am assuming therefore assuming "-isEqual:" in writing my code.   
Someone please let me know if they see any risk in that.



Yes, NSSet and its subclasses use -isEqual:. You should override that,  
as well as -hash.


Nick Zitzmann


___

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

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

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

This email sent to [EMAIL PROTECTED]


tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:

2008-10-15 Thread Chris Idou

For one of my attributes I can't seem to get keyPathsForValuesAffecting to 
do its thing. The following is my code. I'm observing both keys to try and find 
out what's going on. keyPathsForValuesAffectingCanLink does get called. 
observeValueForKeyPath gets called for key noteController.linkableSelection, 
but it never gets called for "canLink".

Shouldn't the existance of keyPathsForValuesAffectingCanLink mean that every 
time the observer gets triggered for noteController.linkableSelection that it 
also gets triggered for canLink? Is there any circumstances it wouldn't? 
Tearing my hair out!



+ (NSSet *)keyPathsForValuesAffectingCanLink {
return [NSSet setWithObject:@"noteController.linkableSelection"];
}

- (void)awakeFromNib {
[self addObserver:self
   forKeyPath:@"noteController.linkableSelection"
   options:NSKeyValueObservingOptionNew
   context:NULL];
[self addObserver:self
   forKeyPath:@"canLink"
   options:NSKeyValueObservingOptionNew
   context:NULL];
}

- (void)observeValueForKeyPath:(NSString *)keyPath
  ofObject:(id)object
  change:(NSDictionary *)change
  context:(void *)context {
 NSLog(@"oVFKP: %@", keyPath);
}

Now, I can fake it by replacing the above function with this, and this works:

- (void)observeValueForKeyPath:(NSString *)keyPath
  ofObject:(id)object
  change:(NSDictionary *)change
  context:(void *)context {
  if ([keyPath isEqualToString:@"noteController.linkableSelection"]) {
 [self willChangeValueForKey:@"canLink"];
 [self didChangeValueForKey:@"canLink"];
  }
 NSLog(@"oVFKP: %@", keyPath);
}

But this is obviously not ideal since I'm doing the job that 
keyPathsForValuesAffectingCanLink is supposed to be doing.










  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Objective-C parameter mutation

2008-10-15 Thread James Trankelson
Hi,

I have a question about method parameters in Objective C. A long time
ago, I had a method like the following:

-(void) foo:(float)val { }

... and when I would call it ([inst foo:0.001], for example), the
value inside the foo method would NOT be 0.001. At the time, I
believed there to be an Objective C requirement that parameters to
methods need to be pointers to objects, not primitive values. So, I
achieved success by changing the above method declaration to

-(void) foo:(NSNumber*)val { }

... and passing in a NSNumber* with a float value worked.

Now, I'm having the same problem, but am not convinced there is any
such requirement that parameters be pointers to object instances. (I
could be wrong, though)

So, I've got the following method:

+ (void)done:(MyObj*)dObj structure:(void*)pStruct

... and when I call it with a "structure" parameter, say a malloc'ed
char* at address 0x171eb070, as soon as I step into this method, the
address is no longer 0x171eb070, but some garbage value that causes
all sorts of trouble. Here's to hoping someone can tell me why this
doesn't work...

Thanks

jt
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Multiple persistent store coordinators gotchas?

2008-10-15 Thread Dave Dribin

On Oct 15, 2008, at 5:52 PM, Melissa J. Turner wrote:
If your second thread is doing pure report generation, and whatever  
transients it sets won't affect anything outside the report  
generation, this is the solution you're looking for.


Great, thanks!

The documentation is a little thin about using multiple PSCs.  Is  
it just a matter of setting up separate Core Data stacks per thread?


Yes.

What are the downsides, especially compared to 1 PSC/multiple  
MOCs?  Higher memory usage?  Separate caches?  Stale data?   
Anything else to watch out for?




The downside tends to be more memory use, since you'll have two  
copies of all the data for each object that is loaded into both  
stacks in addition to the overhead of the stack itself. Stale data  
is unlikely to be a problem unless you're expecting to load it  
significantly before you actually need it, which would be the same  
if you were loading it into a separate context on the same  
coordinator.


Okay, great.  This sounds ideal.  One clarification.  When you say  
"two copies of all the data", doesn't this happen if you had 1 PSC and  
2 MOCs, too?  Each MOC has it's own copy of the data, since they don't  
share managed objects, right?  Or is there some other data that is  
shared in the PSC?


The big upside is that it decreases the amount of time your UI  
thread will be blocked on reads being done by the background thread.


Precisely.  I'm seeing some lock contention between the threads, and I  
want to reduce/eliminate that.  BTW, this is a SQLite store.  Do  
fetches do an exclusive SQL transaction, or is that only done for  
saves?  Just curious if SQLite's locking will affect the threads at  
all, as we're seeing some fetches take a relatively long time (~3  
seconds).  Ideally, the SQLite database won't be locked for that  
period, either, which would also block the UI thread.


-Dave


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Objective-C parameter mutation

2008-10-15 Thread Chris Idou

Works for me.

-(void)aMethod:(void *)mem {
NSLog(@"mem2: %d", mem);
}


- (void)awakeFromNib {
void *memory = malloc(1);
NSLog(@"mem1: %d", memory);
[self aMethod:memory];
}

2008-10-16 11:40:36.815 aProg[30378:813] mem1: 2439440
2008-10-16 11:40:36.815 aProg[30378:813] mem2: 2439440


--- On Wed, 10/15/08, James Trankelson <[EMAIL PROTECTED]> wrote:

> From: James Trankelson <[EMAIL PROTECTED]>
> Subject: Objective-C parameter mutation
> To: "cocoadev List" 
> Date: Wednesday, October 15, 2008, 5:31 PM
> Hi,
> 
> I have a question about method parameters in Objective C. A
> long time
> ago, I had a method like the following:
> 
> -(void) foo:(float)val { }
> 
> ... and when I would call it ([inst foo:0.001], for
> example), the
> value inside the foo method would NOT be 0.001. At the
> time, I
> believed there to be an Objective C requirement that
> parameters to
> methods need to be pointers to objects, not primitive
> values. So, I
> achieved success by changing the above method declaration
> to
> 
> -(void) foo:(NSNumber*)val { }
> 
> ... and passing in a NSNumber* with a float value worked.
> 
> Now, I'm having the same problem, but am not convinced
> there is any
> such requirement that parameters be pointers to object
> instances. (I
> could be wrong, though)
> 
> So, I've got the following method:
> 
> + (void)done:(MyObj*)dObj structure:(void*)pStruct
> 
> ... and when I call it with a "structure"
> parameter, say a malloc'ed
> char* at address 0x171eb070, as soon as I step into this
> method, the
> address is no longer 0x171eb070, but some garbage value
> that causes
> all sorts of trouble. Here's to hoping someone can tell
> me why this
> doesn't work...
> 
> Thanks
> 
> jt
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to
> the list.
> Contact the moderators at
> cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/idou747%40yahoo.com
> 
> This email sent to [EMAIL PROTECTED]


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:

2008-10-15 Thread Ken Thomases

On Oct 15, 2008, at 7:16 PM, Chris Idou wrote:

For one of my attributes I can't seem to get  
keyPathsForValuesAffecting to do its thing. The following is my  
code. I'm observing both keys to try and find out what's going on.  
keyPathsForValuesAffectingCanLink does get called.  
observeValueForKeyPath gets called for key  
noteController.linkableSelection, but it never gets called for  
"canLink".


Shouldn't the existance of keyPathsForValuesAffectingCanLink mean  
that every time the observer gets triggered for  
noteController.linkableSelection that it also gets triggered for  
canLink? Is there any circumstances it wouldn't? Tearing my hair out!


[...]

- (void)observeValueForKeyPath:(NSString *)keyPath
 ofObject:(id)object
 change:(NSDictionary *)change
 context:(void *)context {
NSLog(@"oVFKP: %@", keyPath);


Does it help to invoke super's implementation here?


}


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 [EMAIL PROTECTED]


Re: tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:

2008-10-15 Thread Chris Idou

I can't do that because my object inherits from NSObject, and NSObject doesn't 
contain an implementation of observeValueForKeyPath. So that gives a runtime 
error.

Besides which, the only reason I added observeValueForKeyPath method is because 
keyPathsForValuesAffecting wasn't working.


--- On Wed, 10/15/08, Ken Thomases <[EMAIL PROTECTED]> wrote:

> From: Ken Thomases <[EMAIL PROTECTED]>
> Subject: Re: tearing my hair out: +(NSSet 
> *)keyPathsForValuesAffectingValueForKey:
> To: [EMAIL PROTECTED]
> Cc: cocoa-dev@lists.apple.com
> Date: Wednesday, October 15, 2008, 5:42 PM
> On Oct 15, 2008, at 7:16 PM, Chris Idou wrote:
> 
> > For one of my attributes I can't seem to get  
> > keyPathsForValuesAffecting to do its thing.
> The following is my  
> > code. I'm observing both keys to try and find out
> what's going on.  
> > keyPathsForValuesAffectingCanLink does get called.  
> > observeValueForKeyPath gets called for key  
> > noteController.linkableSelection, but it never gets
> called for  
> > "canLink".
> >
> > Shouldn't the existance of
> keyPathsForValuesAffectingCanLink mean  
> > that every time the observer gets triggered for  
> > noteController.linkableSelection that it also gets
> triggered for  
> > canLink? Is there any circumstances it wouldn't?
> Tearing my hair out!
> >
> > [...]
> >
> > - (void)observeValueForKeyPath:(NSString *)keyPath
> >  ofObject:(id)object
> >  change:(NSDictionary *)change
> >  context:(void *)context {
> > NSLog(@"oVFKP: %@", keyPath);
> 
> Does it help to invoke super's implementation here?
> 
> > }
> 
> 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 [EMAIL PROTECTED]


Re: Objective-C parameter mutation

2008-10-15 Thread Ken Thomases

On Oct 15, 2008, at 7:31 PM, James Trankelson wrote:


I have a question about method parameters in Objective C. A long time
ago, I had a method like the following:

-(void) foo:(float)val { }

... and when I would call it ([inst foo:0.001], for example), the
value inside the foo method would NOT be 0.001. At the time, I
believed there to be an Objective C requirement that parameters to
methods need to be pointers to objects, not primitive values.


Nope, no such requirement.



So, I've got the following method:

+ (void)done:(MyObj*)dObj structure:(void*)pStruct

... and when I call it with a "structure" parameter, say a malloc'ed
char* at address 0x171eb070, as soon as I step into this method, the
address is no longer 0x171eb070, but some garbage value that causes
all sorts of trouble. Here's to hoping someone can tell me why this
doesn't work...


Do a clean build.  Pay attention to and address _all_ warnings.

In particular, the compiler may warn about sending messages that  
haven't been declared.  It may assume parameter types that aren't the  
same as the real method, which can cause garbage to be received.


Also, be careful when stepping in the debugger.  If you step by  
instruction, you may need to step a few instructions into a function/ 
method implementation before the stack frame is set up so that the  
debugger can really interpret the values of arguments.  In other  
words, for the first few instructions it may show you garbage-seeming  
values for arguments and locals.


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 [EMAIL PROTECTED]


Re: Objective-C parameter mutation

2008-10-15 Thread Charles Steinman
--- On Wed, 10/15/08, James Trankelson <[EMAIL PROTECTED]> wrote:

> So, I've got the following method:
> 
> + (void)done:(MyObj*)dObj structure:(void*)pStruct
> 
> ... and when I call it with a "structure"
> parameter, say a malloc'ed
> char* at address 0x171eb070, as soon as I step into this
> method, the
> address is no longer 0x171eb070, but some garbage value
> that causes
> all sorts of trouble. Here's to hoping someone can tell
> me why this
> doesn't work...

Most likely you have a memory-stomping bug somewhere. Can you come up with a 
minimal case to demonstrate the problem? Your pseudocode is hiding whatever is 
wrong. Any type that you could use in a function call is a valid Objective-C 
method parameter.

Cheers,
Chuck


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:

2008-10-15 Thread Jim Correia

On Oct 15, 2008, at 8:46 PM, Chris Idou wrote:

I can't do that because my object inherits from NSObject, and  
NSObject doesn't contain an implementation of  
observeValueForKeyPath. So that gives a runtime error.


NSObject does have an implementation of - 
observeValueForKeyPath:ofObject:change:context: which raises an  
exception for all unknown contexts.


This has been discussed ad naseum on the list.

To properly use KVO you must use a unique context pointer, and  
implement your observer method like this:


- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object  
change:(NSDictionary *)change context:(void *)context

{
if (context == MY_CONTEXT) {
/* do my work here */
} else {
		[super observeValueForKeyPath: keyPath ofObject: object change:  
change context: context];

}
}

Implement it like that always, even when you are a direct subclass of  
NSObject. (If you change your superclass, your implementation will  
still be correct. Etc.)


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 [EMAIL PROTECTED]


Re: -[NSMutableSet addObject:] Ambiguous Docs: -isEqual: vs. ==

2008-10-15 Thread Jerry Krinock


On 2008 Oct, 15, at 17:03, Nick Zitzmann wrote:

Yes, NSSet and its subclasses use -isEqual:. You should override  
that, as well as -hash.


Thanks, Nick.  I don't think I need to override anything though,  
because not adding duplicates based on -isEqual: is indeed the  
behavior that I want.  So, I believe I'm OK in assuming this.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -[NSMutableSet addObject:] Ambiguous Docs: -isEqual: vs. ==

2008-10-15 Thread Jerry Krinock

Sorry, a correction:

adding duplicates based on -isEqual: ^is^ indeed the behavior that I  
want



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Multiple persistent store coordinators gotchas?

2008-10-15 Thread Melissa J. Turner


On Oct 15, 2008, at 17:41, Dave Dribin wrote:


On Oct 15, 2008, at 5:52 PM, Melissa J. Turner wrote:
The downside tends to be more memory use, since you'll have two  
copies of all the data for each object that is loaded into both  
stacks in addition to the overhead of the stack itself. Stale data  
is unlikely to be a problem unless you're expecting to load it  
significantly before you actually need it, which would be the same  
if you were loading it into a separate context on the same  
coordinator.


Okay, great.  This sounds ideal.  One clarification.  When you say  
"two copies of all the data", doesn't this happen if you had 1 PSC  
and 2 MOCs, too?  Each MOC has it's own copy of the data, since they  
don't share managed objects, right?  Or is there some other data  
that is shared in the PSC?




There's data cached down in the store as well, so if you have multiple  
copies of a store (multiple stacks), you have multiple copies of the  
data. If you have 1 PSC and 2 MOCs, we can leverage private  
information about the state of the context and the objects in it to  
decrease memory use (write only caching), but with 2 separate stacks,  
we lose that ability. Just don't try to load and dirty the world ;-)


The big upside is that it decreases the amount of time your UI  
thread will be blocked on reads being done by the background thread.


Precisely.  I'm seeing some lock contention between the threads, and  
I want to reduce/eliminate that.  BTW, this is a SQLite store.  Do  
fetches do an exclusive SQL transaction, or is that only done for  
saves?  Just curious if SQLite's locking will affect the threads at  
all, as we're seeing some fetches take a relatively long time (~3  
seconds).  Ideally, the SQLite database won't be locked for that  
period, either, which would also block the UI thread.




We only open transactions when we update the database. Fetches take a  
read-only lock, so they'll block if there's a writer, and a would be  
writer will have to wait for any reads to finish before it touches any  
tables the reader is using, but overall you should see better  
performance.


+Melissa

___

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

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

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

This email sent to [EMAIL PROTECTED]


table bindings, value transformer per row?

2008-10-15 Thread [EMAIL PROTECTED]
i've got a bound table view. is it possible to use a different value 
transformer based on which row of the table is being 
displayed/edited? and if so, how?


thanx,
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 [EMAIL PROTECTED]


Re: Comparing the Class

2008-10-15 Thread Graham Cox


On 16 Oct 2008, at 12:20 am, Ruotger Skupin wrote:


Hi,

when comparing the class of two objects I usually do [obj1  
isKindOfClass:[obj2 class]]. But if I say have the Class as an input  
value to a method:


- (void) bla:(Class) inClass
{
if (/* inClass is an NSString */)
{
// do stuff
}
else if (/* inClass is an NSNumber */)
{
// do other stuff
}
}

Is it save to compare like this:

inClass == [NSString class]

or do I have to e.g.:

[[NSNumber numberWithInt:0] isKindOfClass:inClass]

Roddi



As well as what others have said, consider not testing the class at  
all but instead testing for a response to a particular message of  
interest (so-called "duck typing" - see http://en.wikipedia.org/wiki/Duck_typing) 
. That can be a lot more flexible. Another option is to declare a  
formal protocol that is common to the possible classes of interest,  
though in the example that wouldn't work because you can't force an  
existing class to conform to a protocol without subclassing.


--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 [EMAIL PROTECTED]


Re: Comparing the Class

2008-10-15 Thread Ken Ferry
> …because you can't force an existing class to conform to a protocol
without subclassing.
A category can add a protocol adoption, actually.

-Ken

On Wed, Oct 15, 2008 at 6:37 PM, Graham Cox <[EMAIL PROTECTED]> wrote:

>
> On 16 Oct 2008, at 12:20 am, Ruotger Skupin wrote:
>
>  Hi,
>>
>> when comparing the class of two objects I usually do [obj1
>> isKindOfClass:[obj2 class]]. But if I say have the Class as an input value
>> to a method:
>>
>> - (void) bla:(Class) inClass
>> {
>>if (/* inClass is an NSString */)
>>{
>>// do stuff
>>}
>>else if (/* inClass is an NSNumber */)
>>{
>>// do other stuff
>>}
>> }
>>
>> Is it save to compare like this:
>>
>>inClass == [NSString class]
>>
>> or do I have to e.g.:
>>
>>[[NSNumber numberWithInt:0] isKindOfClass:inClass]
>>
>> Roddi
>>
>
>
> As well as what others have said, consider not testing the class at all but
> instead testing for a response to a particular message of interest
> (so-called "duck typing" - see http://en.wikipedia.org/wiki/Duck_typing).
> That can be a lot more flexible. Another option is to declare a formal
> protocol that is common to the possible classes of interest, though in the
> example that wouldn't work because you can't force an existing class to
> conform to a protocol without subclassing.
>
> --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/kenferry%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Objective-C parameter mutation

2008-10-15 Thread Graham Cox


On 16 Oct 2008, at 11:31 am, James Trankelson wrote:


... and when I would call it ([inst foo:0.001], for example), the
value inside the foo method would NOT be 0.001. At the time, I
believed there to be an Objective C requirement that parameters to
methods need to be pointers to objects, not primitive values. So, I
achieved success by changing the above method declaration to

-(void) foo:(NSNumber*)val { }

... and passing in a NSNumber* with a float value worked.

Now, I'm having the same problem, but am not convinced there is any
such requirement that parameters be pointers to object instances. (I
could be wrong, though)


You're not wrong, there is no such requirement. A glance at most Cocoa  
classes will reveal methods with simple scalar parameters.


Others have addressed your current problem, but a note about the  
problem of passing 0.001:


A float may not be able to exactly represent 0.001, but a value  
somewhat close to it. When the debugger displays a value it is having  
to do some internal conversion to generate the actual characters  
displayed and there may be some rounding or other adjustment  
occurring. Passing it in an NSNumber may appear to work because it  
*maybe* storing the value internally as a double or in some other form  
that subtly affects the rounding.


Whatever is happening, the fact is that floats cannot store numbers  
arbitrarily precisely. It's obvious really - a float is 32 bits so no  
matter how a value is encoded into those 32 bits, it can only  
represent 2^32-1 possible discrete values.


--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 [EMAIL PROTECTED]


Re: Comparing the Class

2008-10-15 Thread Graham Cox


On 16 Oct 2008, at 12:59 pm, Ken Ferry wrote:


A category can add a protocol adoption, actually.




Cool, I didn't know that :) Obj-C is a great language, isn't it?

--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 [EMAIL PROTECTED]


Re: tearing my hair out: +(NSSet *)keyPathsForValuesAffectingValueForKey:

2008-10-15 Thread Chris Idou
Thanks, that's good to know. But it doesn't solve my particular problem. I'm 
now calling the super class as described, but it doesn't help.

int foo;
int *bar = &foo;

- (void)observeValueForKeyPath:(NSString *)keyPath
  ofObject:(id)object
  change:(NSDictionary *)change
  context:(void *)context {
 NSLog(@"oVFKP: %@", keyPath);
  if (context == bar) {
  } else {
[super observeValueForKeyPath:keyPath ofObject:object change:change 
context:context];
  }
}

--- On Wed, 10/15/08, Jim Correia <[EMAIL PROTECTED]> wrote:

> From: Jim Correia <[EMAIL PROTECTED]>
> Subject: Re: tearing my hair out: +(NSSet 
> *)keyPathsForValuesAffectingValueForKey:
> To: [EMAIL PROTECTED]
> Cc: "Cocoa Developers" 
> Date: Wednesday, October 15, 2008, 5:54 PM
> On Oct 15, 2008, at 8:46 PM, Chris Idou wrote:
> 
> > I can't do that because my object inherits from
> NSObject, and  
> > NSObject doesn't contain an implementation of  
> > observeValueForKeyPath. So that gives a runtime error.
> 
> NSObject does have an implementation of - 
> observeValueForKeyPath:ofObject:change:context: which
> raises an  
> exception for all unknown contexts.
> 
> This has been discussed ad naseum on the list.
> 
> To properly use KVO you must use a unique context pointer,
> and  
> implement your observer method like this:
> 
> - (void)observeValueForKeyPath:(NSString *)keyPath
> ofObject:(id)object  
> change:(NSDictionary *)change context:(void *)context
> {
>   if (context == MY_CONTEXT) {
>   /* do my work here */
>   } else {
>   [super observeValueForKeyPath: keyPath ofObject: object
> change:  
> change context: context];
>   }
> }
> 
> Implement it like that always, even when you are a direct
> subclass of  
> NSObject. (If you change your superclass, your
> implementation will  
> still be correct. Etc.)
> 
> 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 [EMAIL PROTECTED]


Re: Comparing the Class

2008-10-15 Thread Chris Idou

A category could be a nice OO solution here that avoids having the dreaded if 
else.


--- On Wed, 10/15/08, Ken Ferry <[EMAIL PROTECTED]> wrote:

> From: Ken Ferry <[EMAIL PROTECTED]>
> Subject: Re: Comparing the Class
> To: "Graham Cox" <[EMAIL PROTECTED]>
> Cc: "cocoa-dev Dev" 
> Date: Wednesday, October 15, 2008, 6:59 PM
> > …because you can't force an existing class to
> conform to a protocol
> without subclassing.
> A category can add a protocol adoption, actually.
> 
> -Ken
> 
> On Wed, Oct 15, 2008 at 6:37 PM, Graham Cox
> <[EMAIL PROTECTED]> wrote:
> 
> >
> > On 16 Oct 2008, at 12:20 am, Ruotger Skupin wrote:
> >
> >  Hi,
> >>
> >> when comparing the class of two objects I usually
> do [obj1
> >> isKindOfClass:[obj2 class]]. But if I say have the
> Class as an input value
> >> to a method:
> >>
> >> - (void) bla:(Class) inClass
> >> {
> >>if (/* inClass is an NSString */)
> >>{
> >>// do stuff
> >>}
> >>else if (/* inClass is an NSNumber */)
> >>{
> >>// do other stuff
> >>}
> >> }
> >>
> >> Is it save to compare like this:
> >>
> >>inClass == [NSString class]
> >>
> >> or do I have to e.g.:
> >>
> >>[[NSNumber numberWithInt:0]
> isKindOfClass:inClass]
> >>
> >> Roddi
> >>
> >
> >
> > As well as what others have said, consider not testing
> the class at all but
> > instead testing for a response to a particular message
> of interest
> > (so-called "duck typing" - see
> http://en.wikipedia.org/wiki/Duck_typing).
> > That can be a lot more flexible. Another option is to
> declare a formal
> > protocol that is common to the possible classes of
> interest, though in the
> > example that wouldn't work because you can't
> force an existing class to
> > conform to a protocol without subclassing.
> >
> > --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/kenferry%40gmail.com
> >
> > This email sent to [EMAIL PROTECTED]
> >
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to
> the list.
> Contact the moderators at
> cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/idou747%40yahoo.com
> 
> This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -[NSGarbageCollection disableCollectorForPointer:] ?

2008-10-15 Thread Ken Ferry
Or you could malloc the memory for the buffer (free'ing it when you're done)
and disable/enable collection on any objects pointers you store in it that
you also want to keep alive.  Maybe that's easier to understand.
(Any time you use disableCollectorForPointer is a possible leak, by the way.
 The object will be rooted until you reenable collection, so don't try to
reenable collection from within the finalizer of an object that the rooted
object will keep alive.  That's an uncollectable cycle.)

-Ken

On Wed, Oct 15, 2008 at 4:45 PM, Ken Ferry <[EMAIL PROTECTED]> wrote:

> > What I did try was
> >
> 'NSPointerFunctionsStrongMemory|NSPointerFunctionsObjectPointerPersonality'
> > which does work even though some of the pointers aren't objects and this
> > doesn't seem quite correct but since I'm using GC
> > NSPointerFunctionsObjectPointerPersonality seems nearly equivalent to
> > NSPointerFunctionsOpaquePersonality as long as description isn't called.
>
> I see.. I think it's a bug that 
> NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory
> is rejected.
>
> It's probably not very future safe to add non-objects with the object
> personality.  You might prefer to use NSAllocateCollectable(NSScannedOption)
> and forego the pointer array.  This allocates a chunk of memory that is:
>
> (1) Collected by the collector when unreachable by strong reference chain
> from a gc-root.
> (2) Conservatively scanned.
>
> To keep the memory alive when used as the void* contextInfo, you'd still
> need to use -[NSGarbageCollector disableCollectorForPointer:].
>
> The main gotcha is that any stores of gc objects into the buffer need to
> generate write barriers, which are calls into the objective-c library that
> let the collector know that the the buffer has changed and needs to be
> rescanned next time a collection runs.  This should Just Work provided the
> type of the buffer is __strong, but you can put doubt to rest by checking
> that the compiler emitted the function calls.  In Xcode, right click and
> choose "Show Assembly Code", then look for the calls.  For example, this
>
> - (void)writeToCollectableMemory:(NSObject *)object {
>
> int bufferLength = 5;
>
> __strong void **buffer = (__strong void**)NSAllocateCollectable(sizeof
> (void*)*bufferLength, NSScannedOption);
>
> buffer[3] = [[NSObject alloc] init];
> …
>
> compiles to this.  objc_assign_strongCast is the function call.
>
> "-[MyBlockOperation writeToCollectableMemory:]":
>
> LFB672:
>
> LM221:
>
> LVL93:
>
> pushl %ebp
>
> LCFI337:
>
> movl %esp, %ebp
>
> LCFI338:
>
> pushl %esi
>
> LCFI339:
>
> pushl %ebx
>
> LCFI340:
>
> subl $16, %esp
>
> LCFI341:
>
> call L245
>
> "L076$pb":
>
> L245:
>
> popl %ebx
>
> LM222:
>
> movl $1, 4(%esp)
>
> movl $20, (%esp)
>
> call _NSAllocateCollectable
>
> movl %eax, %esi
>
> LM223:
>
> movl L_OBJC_SELECTOR_REFERENCES_3-"L076$pb"(%ebx), %eax
>
> movl %eax, 4(%esp)
>
> movl L_OBJC_CLASS_REFERENCES_0-"L076$pb"(%ebx), %eax
>
> movl %eax, (%esp)
>
> call _objc_msgSend
>
> movl L_OBJC_SELECTOR_REFERENCES_4-"L076$pb"(%ebx), %edx
>
> movl %edx, 4(%esp)
>
> movl %eax, (%esp)
>
> call _objc_msgSend
>
> leal 12(%esi), %edx
>
> movl %edx, 4(%esp)
>
> movl %eax, (%esp)
>
> call *_objc_assign_strongCast*
> …
>
> -Ken
> Cocoa Frameworks
>
> On Wed, Oct 15, 2008 at 9:32 AM, Michael Link <[EMAIL PROTECTED]> wrote:
> > That makes sense, although
> > 'NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory' gives the
> > error:
> >
> > *** -[NSPointerArray initWithOptions:] Requested configuration not
> > supported.
> >
> > What I did try was
> >
> 'NSPointerFunctionsStrongMemory|NSPointerFunctionsObjectPointerPersonality'
> > which does work even though some of the pointers aren't objects and this
> > doesn't seem quite correct but since I'm using GC
> > NSPointerFunctionsObjectPointerPersonality seems nearly equivalent to
> > NSPointerFunctionsOpaquePersonality as long as description isn't called.
> >
> > --
> > Michael
> >
> > On Oct 15, 2008, at 1:08 AM, Ken Ferry wrote:
> >
> >> Hi Michael,
> >>
> >> NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory doesn't
> >> make sense. You're meant to specify only one of the memory options and
> >> only one of the personality options.
> >>
> >> Due to the way the bitfield work, your invocation is the same as
> >> NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality.
> >> This is the mode in which the pointer array is completely hands-off.
> >> It acts like a C array.
> >>
> >> Try NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaquePersonality.
> >> That sounds right to me, though I get confused with the pointer
> >> functions too.
> >>
> >> -Ken
> >>
> >> On Tue, Oct 14, 2008 at 9:43 PM, Michael Link <[EMAIL PROTECTED]>
> wrote:
> >>>
> >>> I have a situation where I create an NSPointerArray on the stack by:
> >>>
> >>> pointers = [NSPointerArray
> >>>
> >>>
> pointerArrayWithOptions:NSPointerFunctionsStro

Re: Comparing the Class

2008-10-15 Thread Michael Ash
On Wed, Oct 15, 2008 at 6:17 PM, Melissa J. Turner <[EMAIL PROTECTED]> wrote:
> It's generally unwise to do this kind of thing if you're dealing with class
> clusters or bridged classes (which category includes both NSString and
> NSNumber). The class you actually get may not be what you're expecting.

This is the case with all classes, not just the ones you mention.
Something as simple as using Key-Value Observing on an object can
change its class to a subclass of the original, causing direct
equality comparisons to fail.

If you can, avoid class comparisons altogether. There are usually
better techniques available which take advantage of the dynamism of
the language. (For example, defining the same method on all the
classes you will process, and having that method do something
different in each class, as you need.) If you cannot avoid class
comparisons, then you must always compare in such a way as to take
subclasses into account. This is just good OO sense: an instance of a
class is also an instance of any superclass of that class, and should
be accepted equally.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread han
I want to complete a vigorous file transfer application.The server is 
implemented in the max os x,and client in the windows.

I think  the  app is  flexible, scalable, reusable.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Comparing the Class

2008-10-15 Thread Ken Ferry
On Wed, Oct 15, 2008 at 7:18 PM, Chris Idou <[EMAIL PROTECTED]> wrote:

>
> A category could be a nice OO solution here that avoids having the dreaded
> if else.


..as long as the method name is not too generic.

Early in Leopard, iChat and Mail both had some mysteriously broken behavior
with some AppKit code for interpreting an object that originally came from
user defaults.  It looked something like this:

if ([default respondsToSelector:@selector(boolValue)])
return [default boolValue];
else if ([default isKindOfClass:[NSString class]]) {
return {determination if string looks like a @"YES" or a @"1" or
whatever goes here}
}

The problem was that Message.framework, which was loaded by both, had a
category that defined boolValue on NSString, and the definition of what
strings were considered true was a little bit different than the
determination in AppKit.  So any app that loaded Message.framework (which is
a public framework) would interpret certain a global defaults differently
that any other app.

This particular issue won't come up again, because 10.5 introduced
-[NSString boolValue], and the AppKit code was rewritten anyway.  :-)  But
the point is, categories pollute the global space of methods.  They're
great! But when adding methods to framework classes, use method names that
no one else would be interested in, by prefixing if nothing else.

-Ken
Cocoa Frameworks


>
>
> --- On Wed, 10/15/08, Ken Ferry <[EMAIL PROTECTED]> wrote:
>
> > From: Ken Ferry <[EMAIL PROTECTED]>
> > Subject: Re: Comparing the Class
> > To: "Graham Cox" <[EMAIL PROTECTED]>
> > Cc: "cocoa-dev Dev" 
> > Date: Wednesday, October 15, 2008, 6:59 PM
> > > …because you can't force an existing class to
> > conform to a protocol
> > without subclassing.
> > A category can add a protocol adoption, actually.
> >
> > -Ken
> >
> > On Wed, Oct 15, 2008 at 6:37 PM, Graham Cox
> > <[EMAIL PROTECTED]> wrote:
> >
> > >
> > > On 16 Oct 2008, at 12:20 am, Ruotger Skupin wrote:
> > >
> > >  Hi,
> > >>
> > >> when comparing the class of two objects I usually
> > do [obj1
> > >> isKindOfClass:[obj2 class]]. But if I say have the
> > Class as an input value
> > >> to a method:
> > >>
> > >> - (void) bla:(Class) inClass
> > >> {
> > >>if (/* inClass is an NSString */)
> > >>{
> > >>// do stuff
> > >>}
> > >>else if (/* inClass is an NSNumber */)
> > >>{
> > >>// do other stuff
> > >>}
> > >> }
> > >>
> > >> Is it save to compare like this:
> > >>
> > >>inClass == [NSString class]
> > >>
> > >> or do I have to e.g.:
> > >>
> > >>[[NSNumber numberWithInt:0]
> > isKindOfClass:inClass]
> > >>
> > >> Roddi
> > >>
> > >
> > >
> > > As well as what others have said, consider not testing
> > the class at all but
> > > instead testing for a response to a particular message
> > of interest
> > > (so-called "duck typing" - see
> > http://en.wikipedia.org/wiki/Duck_typing).
> > > That can be a lot more flexible. Another option is to
> > declare a formal
> > > protocol that is common to the possible classes of
> > interest, though in the
> > > example that wouldn't work because you can't
> > force an existing class to
> > > conform to a protocol without subclassing.
> > >
> > > --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/kenferry%40gmail.com
> > >
> > > This email sent to [EMAIL PROTECTED]
> > >
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator comments to
> > the list.
> > Contact the moderators at
> > cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> > http://lists.apple.com/mailman/options/cocoa-dev/idou747%40yahoo.com
> >
> > This email sent to [EMAIL PROTECTED]
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kenferry%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread Rohan Lloyd


On 16 Oct 2008, at 1:24 PM, han wrote:

I want to complete a vigorous file transfer application.The server  
is implemented in the max os x,and client in the windows.

I think  the  app is  flexible, scalable, reusable.


What about ftp, sftp or scp?


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to complete c/s app

2008-10-15 Thread Andrew Farmer

On 15 Oct 08, at 19:24, han wrote:
I want to complete a vigorous file transfer application.The server  
is implemented in the max os x,and client in the windows.

I think  the  app is  flexible, scalable, reusable.


That looks like a sound set of requirements, but what it isn't is a  
question. With all due respect, you're going to have to figure out how  
to satisfy them on your own - we can't write your application for you.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Dial with Bluetooth

2008-10-15 Thread Thomas Bartelmess
Hello everyone!

I would like to know if anybody has some expirience with the IOBluetooth 
Classes. Can you tell me how hard it is to Dial a number on a Phone with 
Bluetooth. I'm new to Bluetooth (I don't know very much about it) so please 
don't be too rude.

Thanks a lot

Thomas



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: -[NSGarbageCollection disableCollectorForPointer:] ?

2008-10-15 Thread Michael Link
I actually went with using NSAllocateCollectable(NSScannedOption) and  
that seems to be working well. Thanks.


--
Michael

On Oct 15, 2008, at 9:21 PM, Ken Ferry wrote:

Or you could malloc the memory for the buffer (free'ing it when  
you're done) and disable/enable collection on any objects pointers  
you store in it that you also want to keep alive.  Maybe that's  
easier to understand.


(Any time you use disableCollectorForPointer is a possible leak, by  
the way.  The object will be rooted until you reenable collection,  
so don't try to reenable collection from within the finalizer of an  
object that the rooted object will keep alive.  That's an  
uncollectable cycle.)


-Ken

On Wed, Oct 15, 2008 at 4:45 PM, Ken Ferry <[EMAIL PROTECTED]> wrote:
> What I did try was
> 'NSPointerFunctionsStrongMemory| 
NSPointerFunctionsObjectPointerPersonality'
> which does work even though some of the pointers aren't objects  
and this

> doesn't seem quite correct but since I'm using GC
> NSPointerFunctionsObjectPointerPersonality seems nearly equivalent  
to
> NSPointerFunctionsOpaquePersonality as long as description isn't  
called.


I see.. I think it's a bug that NSPointerFunctionsStrongMemory| 
NSPointerFunctionsOpaqueMemory is rejected.


It's probably not very future safe to add non-objects with the  
object personality.  You might prefer to use  
NSAllocateCollectable(NSScannedOption) and forego the pointer  
array.  This allocates a chunk of memory that is:


(1) Collected by the collector when unreachable by strong reference  
chain from a gc-root.

(2) Conservatively scanned.

To keep the memory alive when used as the void* contextInfo, you'd  
still need to use -[NSGarbageCollector disableCollectorForPointer:].


The main gotcha is that any stores of gc objects into the buffer  
need to generate write barriers, which are calls into the objective- 
c library that let the collector know that the the buffer has  
changed and needs to be rescanned next time a collection runs.  This  
should Just Work provided the type of the buffer is __strong, but  
you can put doubt to rest by checking that the compiler emitted the  
function calls.  In Xcode, right click and choose "Show Assembly  
Code", then look for the calls.  For example, this


- (void)writeToCollectableMemory:(NSObject *)object {
int bufferLength = 5;
__strong void **buffer = (__strong  
void**)NSAllocateCollectable(sizeof(void*)*bufferLength,  
NSScannedOption);

buffer[3] = [[NSObject alloc] init];
…

compiles to this.  objc_assign_strongCast is the function call.

"-[MyBlockOperation writeToCollectableMemory:]":
LFB672:
LM221:
LVL93:
pushl   %ebp
LCFI337:
movl%esp, %ebp
LCFI338:
pushl   %esi
LCFI339:
pushl   %ebx
LCFI340:
subl$16, %esp
LCFI341:
callL245
"L076$pb":
L245:
popl%ebx
LM222:
movl$1, 4(%esp)
movl$20, (%esp)
call_NSAllocateCollectable
movl%eax, %esi
LM223:
movlL_OBJC_SELECTOR_REFERENCES_3-"L076$pb"(%ebx), %eax
movl%eax, 4(%esp)
movlL_OBJC_CLASS_REFERENCES_0-"L076$pb"(%ebx), %eax
movl%eax, (%esp)
call_objc_msgSend
movlL_OBJC_SELECTOR_REFERENCES_4-"L076$pb"(%ebx), %edx
movl%edx, 4(%esp)
movl%eax, (%esp)
call_objc_msgSend
leal12(%esi), %edx
movl%edx, 4(%esp)
movl%eax, (%esp)
call_objc_assign_strongCast
…

-Ken
Cocoa Frameworks

On Wed, Oct 15, 2008 at 9:32 AM, Michael Link <[EMAIL PROTECTED]>  
wrote:

> That makes sense, although
> 'NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory'  
gives the

> error:
>
> *** -[NSPointerArray initWithOptions:] Requested configuration not
> supported.
>
> What I did try was
> 'NSPointerFunctionsStrongMemory| 
NSPointerFunctionsObjectPointerPersonality'
> which does work even though some of the pointers aren't objects  
and this

> doesn't seem quite correct but since I'm using GC
> NSPointerFunctionsObjectPointerPersonality seems nearly equivalent  
to
> NSPointerFunctionsOpaquePersonality as long as description isn't  
called.

>
> --
> Michael
>
> On Oct 15, 2008, at 1:08 AM, Ken Ferry wrote:
>
>> Hi Michael,
>>
>> NSPointerFunctionsStrongMemory|NSPointerFunctionsOpaqueMemory  
doesn't
>> make sense. You're meant to specify only one of the memory  
options and

>> only one of the personality options.
>>
>> Due to the way the bitfield work, your invocation is the same as
>> NSPointerFunctionsOpaqueMemory|NSPointerFunctionsOpaquePersonality.
>> This is the mode in which the pointer array is completely hands- 
off.

>> It acts like a C array.
>>
>> Try NSPointerFunctionsStrongMemory| 
NSPointerFunctionsOpaquePersonality.

>> That sounds right to me, though I get confused with the pointer
>> functions too.
>>
>> -Ken
>>
>> On Tue, Oct 14, 2008 at 9:43 PM, Michael Link <[EMAIL PROTECTED]>  
wrote:

>>>
>>> I have a situation where I create an NSPointerArray on the stack  
by:

>>>
>>> pointers = [NSPointerArray
>>>
>>> pointerArrayWithOptions:NSPointerFunctio

CoreData: "Unacceptable type of value for to-one relationship"

2008-10-15 Thread Pavel Kapinos

Hi,

I am using an abstract entity as a destination for to-one relationship  
but assign an instance of its concrete subentity and it worked just  
fine in Tiger and even in early 10.5, but I am getting now this nasty  
"Unacceptable type of value for to-one relationship" runtime messages  
in 10.5.5 and have no clue why would this be happening. I would very  
much appreciate any enlightening suggestions. Thank you.

___

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

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

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

This email sent to [EMAIL PROTECTED]


tearing my hair, ok here is a compilable example.

2008-10-15 Thread Chris Idou
I've attached code that shows what I'm talking about with my 
keyPathsForValuesAffectingValueForKey problem. If anyone wants me to send a zip 
file (60kb) xcode project, jet let me know. For those who just want to see the 
code, I've appended it here also. To compile, just put the 2 classes in a 
project. Make a NSObjectController and NSObject in IB, link class2 to class1 
outlet, and create a button linked to change: to make it do stuff.

Can anyone tell me why myMethod isn't called by observeValueForKeyPath when you 
press the button and call change: ?

#import 


@interface Class1 : NSObjectController {
BOOL canLink;
}
-(BOOL)canLink;

- (IBAction)change:(id)v;


@end


#import "Class1.h"


@implementation Class1

-(BOOL)canLink {
NSLog(@"canLink: %d nc:%d", canLink, self);
return canLink;
}


- (IBAction)change:(id)v; {
[self willChangeValueForKey:@"canLink"];
canLink = !canLink;
[self didChangeValueForKey:@"canLink"];
NSLog(@"change:%d", canLink);
}

@end

#import 

@class Class1;
@interface Class2 : NSObject {
IBOutlet Class1 *class1;


}
@property(readonly) Class1 *class1;
-(BOOL)myMethod;
@end

#import "Class2.h"
#import "Class1.h"

@implementation Class2

@synthesize class1;

- (void)observeValueForKeyPath:(NSString *)keyPath
  ofObject:(id)object
change:(NSDictionary *)change
   context:(void *)context {
NSLog(@"ovfkp: %@", keyPath);
if (context == [Class2 class]) {
if ([keyPath isEqualToString:@"myMethod"]) {
NSLog(@"newvalue - myMethod:%d", [self myMethod]);
}
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change 
context:context];
}
}

- (void)awakeFromNib {
[self addObserver:self
   forKeyPath:@"myMethod"
  options:NSKeyValueObservingOptionNew
  context: [Class2 class]];

}


+ (NSSet *)keyPathsForValuesAffectingMyMethod {
NSLog(@"keyPathsForValuesAffectingMyMethod");
return [NSSet setWithObject:@"class1.canLink"];
}

-(BOOL)myMethod {
return [class1 canLink];
}


@end




  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: tearing my hair, ok here is a compilable example.

2008-10-15 Thread Quincey Morris

On Oct 15, 2008, at 22:13, Chris Idou wrote:


@class Class1;
@interface Class2 : NSObject {
   IBOutlet Class1 *class1;


}
@property(readonly) Class1 *class1;
-(BOOL)myMethod;
@end

#import "Class2.h"
#import "Class1.h"

@implementation Class2

@synthesize class1;

...

- (void)awakeFromNib {
   [self addObserver:self
  forKeyPath:@"myMethod"
 options:NSKeyValueObservingOptionNew
 context: [Class2 class]];

}


+ (NSSet *)keyPathsForValuesAffectingMyMethod {
   NSLog(@"keyPathsForValuesAffectingMyMethod");
   return [NSSet setWithObject:@"class1.canLink"];
}


I think your problem is that Class2 isn't properly KVO compliant for  
the key "class1". Consider what happens when your nib is loaded. At  
some point, the nib loader needs to set "class1" to its correct value.  
Since the property is readonly and synthesized, there's no setter  
method, so the instance variable is changed directly. (I'm going from  
memory here, but I believe that's what documented to happen.) That  
presumably fails to trigger any KVO notifications, and your  
"keyPathsForValuesAffectingMyMethod" is not consulted.


Try this:


...



@interface Class2 ()



@property(readwrite) Class1 *class1;
@end







@implementation Class2

@synthesize class1;



If my theory is correct, that should cause the outlet to be set via a  
KVC-compliant setter, and the keypath dependency should start working.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Dial with Bluetooth

2008-10-15 Thread Nick Zitzmann


On Oct 15, 2008, at 4:20 PM, Thomas Bartelmess wrote:

I would like to know if anybody has some expirience with the  
IOBluetooth Classes. Can you tell me how hard it is to Dial a number  
on a Phone with Bluetooth. I'm new to Bluetooth (I don't know very  
much about it) so please don't be too rude.



It isn't that hard, but it only works with the small handful of phones  
that support RFCOMM. Apple most certainly does not support RFCOMM on  
the **; I've only seen some Nokia and Sony Ericsson phones support  
it.


Nick Zitzmann




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: tearing my hair, ok here is a compilable example.

2008-10-15 Thread Chris Idou
That thought had occured to me, but making it readwrite doesn't seem to help. 
Cocoa NIB loading doesn't seem to call accessors, it seems to access them more 
directly. I even tried this:


-(Class1 *)class1 {
return class1;
}

-(void)setClass1:(Class1 *)v {
NSLog(@"setClass1: %@", v);
[self willChangeValueForKey:@"class1"];
class1 = v;
[self didChangeValueForKey:@"class1"];
}

But they don't get called.

I even tried adding to awakeFromNIB:

id old = [self class1];
[self setClass1:nil];
[self setClass1:old];

To try and force the issue, but to no avail.

Someone has observed that my code works when called from main() and bypassing 
IB. But it still doesn't work when loaded from a NIB!


--- On Wed, 10/15/08, Quincey Morris <[EMAIL PROTECTED]> wrote:

> From: Quincey Morris <[EMAIL PROTECTED]>
> Subject: Re: tearing my hair, ok here is a compilable example.
> To: cocoa-dev@lists.apple.com
> Date: Wednesday, October 15, 2008, 10:54 PM
> On Oct 15, 2008, at 22:13, Chris Idou wrote:
> 
> > @class Class1;
> > @interface Class2 : NSObject {
> >IBOutlet Class1 *class1;
> >
> >
> > }
> > @property(readonly) Class1 *class1;
> > -(BOOL)myMethod;
> > @end
> >
> > #import "Class2.h"
> > #import "Class1.h"
> >
> > @implementation Class2
> >
> > @synthesize class1;
> >
> > ...
> >
> > - (void)awakeFromNib {
> >[self addObserver:self
> >   forKeyPath:@"myMethod"
> >  options:NSKeyValueObservingOptionNew
> >  context: [Class2 class]];
> >
> > }
> >
> >
> > + (NSSet *)keyPathsForValuesAffectingMyMethod {
> >   
> NSLog(@"keyPathsForValuesAffectingMyMethod");
> >return [NSSet
> setWithObject:@"class1.canLink"];
> > }
> 
> I think your problem is that Class2 isn't properly KVO
> compliant for  
> the key "class1". Consider what happens when your
> nib is loaded. At  
> some point, the nib loader needs to set "class1"
> to its correct value.  
> Since the property is readonly and synthesized, there's
> no setter  
> method, so the instance variable is changed directly.
> (I'm going from  
> memory here, but I believe that's what documented to
> happen.) That  
> presumably fails to trigger any KVO notifications, and your
>  
> "keyPathsForValuesAffectingMyMethod" is not
> consulted.
> 
> Try this:
> 
> > ...
> 
> > @interface Class2 ()
> 
> > @property(readwrite) Class1 *class1;
> > @end
> 
> >
> 
> > @implementation Class2
> >
> > @synthesize class1;
> > 
> 
> If my theory is correct, that should cause the outlet to be
> set via a  
> KVC-compliant setter, and the keypath dependency should
> start working.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to
> the list.
> Contact the moderators at
> cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/idou747%40yahoo.com
> 
> This email sent to [EMAIL PROTECTED]


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSComboBox select change

2008-10-15 Thread Joseph Yu
Hi

When the combobox change the selection,I want to do something.

How to do this?

I didn't see any callback function.

Or set the NSControl?



***
The opinions and views expressed in this e-mail are solely those of the author 
and do not necessarily represent those of Qisda Corporation and its affiliates. 
Qisda Corporation is not responsible for any liability or damaged caused by 
viruses transmitted with this e-mail or its attachments. If this e-mail is not 
originally intended for you, or received by you in error, do not disclose its 
content to anyone and delete it immediately. This e-mail may contain 
information that is private, legally privileged, confidential or exempt from 
disclosure, and intended for the sole use of the intended recipient. Any 
review, copying, or distribution of this email (or any attachments thereto) by 
others is strictly prohibited. Thank you. 
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Objective-C parameter mutation

2008-10-15 Thread Sherm Pendley
On Wed, Oct 15, 2008 at 10:07 PM, Graham Cox <[EMAIL PROTECTED]> wrote:

>
> Others have addressed your current problem, but a note about the problem of
> passing 0.001:
>
> A float may not be able to exactly represent 0.001, but a value somewhat
> close to it.


Spot-on!

Goldberg's classic paper on the subject is a must-read for anyone working
with floats:



sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

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

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

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

This email sent to [EMAIL PROTECTED]