Re: Garbage Collection woes...

2008-06-29 Thread Stephen J. Butler
On Fri, Jun 27, 2008 at 2:31 PM, John Engelhart
[EMAIL PROTECTED] wrote:
 Lesson #2:  Since there is so little documentation about the GC system, this
 involves a lot of speculation, but I think it summarizes what's really going
 on.  This all started with an effort to keep a __weak reference to a passed
 in string that was used to initialize an element in a cache.  When the cache
 was checked, if that weak reference was NULL, then the cache line is invalid
 and should be cleared.  The cache consisted of a global array of elements,
 selection was done via KEY_STRING_HASH % CACHE_SIZE, and everything was
 under a mutex lock.  An approximation of the cache is:

 typedef struct {
  NSString *aString;
  __weak NSString *aWeakString;
  NSInteger anInteger;
 } MYStructType;

 MYStructType globalStructTypeArray[42]; // -- Global!

 Simple, right?  That's how it always starts out...  The first problem
 encountered was:

 [EMAIL PROTECTED] /tmp% gcc -o Global_GC Global_GC.m -framework Foundation
 -fobjc-gc
 Global_GC.m:14: warning: __weak attribute cannot be specified on a field
 declaration

 (The attached file contains the full example demonstrating the problem.)

 I'm not really sure what this means, and I don't recall reading anything in
 the documentation that would suggest anything is amiss.  I never actually
 managed to figure out what, if any, problem this causes because it quickly
 became apparent that there was a much bigger problem that needed dealing
 with:

Speculation: __weak needs a read-barrier as well as a write-barrier,
and with structs people have a long history of reading them without
going through the accessor. This isn't generally a problem for
__strong and write barriers because for all of this to work you need
to make sure that the memory for MYStructType is GC scanned anyway.

 The pointer to 'aString' in the above (or any of my other __strong pointers
 in my actual code) were clearly not being treated as __strong, and the GC
 system was reclaiming them causing all sorts of fun and random crashes.

 The documentation states: The initial root set of objects is comprised of
 global variables, stack variables, and objects with external references.
 These objects are never considered as garbage.

This is kind of a lie since not ALL global memory is treated as
collectable. Hence the need for special assigns.

 Putting the pieces together, it became obvious what was really going on.
  The two commented out lines in the example that update the global variable
 are the key to the mystery and make everything work as expected.

 It turns out that when the documentation says that root set of objects is
 comprised of global variables, it's true, but probably not in the way that
 you think it is.

 It would 'seem' that global variables are only __strong when the compiler
 can reason that you're referring to a global variable directly. In this
 particular case, that would be:

 globalStructTypeArray[23].aString = newString;

Speculation: another way to think of it is that not all global memory
is considered a collectable root until you've first used it. That is,
on the first call to objc_assign_global, the pointer is added to the
list of collectable roots. It appears to be a lazy sort of system.

 They are not strong when you refer to them indirectly (even though write
 barriers are clearly being performed), such as:

 update(globalStructTypeArray[23], newString);

 update(MYStructType *aStructType, NSString *string) {
  aStructType-aString = string;
 }

 Looking at the assembly output, the reason becomes clear:

 The write barrier used by the first, direct reference is objc_assign_global,
 while the write barrier used by the indirect reference in update is
 objc_assign_strongCast.

 This is probably an important point that you should consider if you're
 depending on global variables being truly __strong.  No doubt someone here
 will explain that this isn't a bug, it's just that you shouldn't reference a
 global variable via a pointer (this is sarcastic for the challenged).

You shouldn't reference a global variable via a pointer! Kidding.

The problem is essentially the same as the one in this code:

class Foo {
  public:
  NSString* fieldA;
  int fieldB;

  Foo( NSString *_fieldA, int _fieldB ) : fieldA( _fieldA ), fieldB(
_fieldB ) {}
};

Foo *f = new Foo( @Something strong, 42 );

IIRC, you'll also find that here f-fieldA is collected way before you
expect. Only this time, there's plenty of emails about how to fix it.
The problem is that ::new returns a block of non-GC memory. So even
though the write barriers are setup properly, f-fieldA is in a
non-scanned region. See here:

http://lists.apple.com/archives/Cocoa-dev/2008/Feb/msg00435.html

In your case, globalStructTypeArray is also in a non-scanned region,
which is why the compiler uses the special _global assign. But you've
hidden the global nature from the compiler by using the pointer, so it
fails.

 I'll leave you to ponder the implications 

Re: Methods that return autoreleased objects?

2008-06-29 Thread mmalc crawford


On Jun 28, 2008, at 9:59 PM, Charles Srstka wrote:

Methods that begin with alloc or new or contain copy will  
return objects you are responsible for. All other objects returned  
from methods are taken care of.


Well, there is the notable exception of top-level objects loaded  
from a NIB file, which do need to be released.



... which is documented:
	http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_3.html# 



mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: mutableArrayForKeyValue Question (ignore other email)

2008-06-29 Thread Scott Anguish

I think there is still some clarification necessary.

what exactly are you trying to accomplish, rather than how you are  
trying to do it?


would I be correct to guess that you want to create a new Person  
object and add it to the array?


if so you need to create the object and add it to the array

id newObjectToAdd = [theArrayController newObject];
[theArrayController addObject:newObjectToAdd];



or you can programmatically create the Person object, and add it  
directly to the datamodel using, say


Person *aPerson=[[[Person alloc] init] autorelease];
and then add that to the data model using the mutableArrayforKeyValue:

On Jun 28, 2008, at 10:42 PM, Alex Wait wrote:

Gmail sent an email on me while I was typing. No idea what  
happened! :) So

please ignore the incomplete message.

I have successfully done some more bindings (they're so much fun ^_^ )

I am trying to modify the array controller programmatically and I'm  
running

into problems using mutableArrayForKeyValue

I am using this line

   id proxy = [controller mutableArrayValueForKey:@Person];

when I do
   [proxy addObject:newPerson]

I get

[NSArrayController 0x130050 valueForUndefinedKey:]: this class is  
not key

value coding-compliant for the key Person.

In IB I have bound the Content Array to my array member in App  
Controller.

Shouldn't this work?
I have set the class name to be of the Person class. Right now the  
key I
am using is Person but I have also tried array and got the same  
problem.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why aren't my bindings firing?

2008-06-29 Thread Ken Thomases

On Jun 28, 2008, at 10:17 AM, Charles Srstka wrote:

I think what we can all take home from this is that the  
documentation for bindings needs to be clearer and less self- 
contradictory on the very basic concept of exactly what Cocoa  
Bindings *is*.


For what it's worth, after sending my previous message, I did file a  
documentation enhancement request using the It's good, but link.   
Hopefully, I described my confusion and the several seemingly- 
contradictory implications of the documentation well enough to be  
useful to the good folks at Apple.


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: Garbage Collection woes...

2008-06-29 Thread mmalc crawford


On Jun 27, 2008, at 12:31 PM, John Engelhart wrote:


-(BOOL)doSomething:(id)obj error:(NSError **)error
{
 if(error != NULL) { *error = NULL; } // Make sure we clear the  
error object

}


Why are you doing this?

It's sort of ambiguous as to what should be returned by the indirect  
error pointer on the condition of success.  I could think of several  
neat ideas if the expected behavior were defined up front, even  
requiring the caller to initialize the pointer to a default NSError  
singleton and allowing errors to accumulate in a stack like  
fashion.  Alas, the only clearly defined behavior is that one  
failure, a NSError object is indirectly returned.



That's exactly what's expected.
In general, a method should signal an error condition by—for example— 
returning NO or nilrather than by the simple presence of an error  
object. The method can then optionally return an NSError object by  
reference, in order to further describe the error.


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: noob question regarding proxy object returned by -selection method of NSArrayController

2008-06-29 Thread Ken Thomases

On Jun 28, 2008, at 12:43 PM, Stuart Malin wrote:

I have a button in the GUI that should cause various changes to the  
person selected in the table. In the method that is the target of  
the button's action, I need to get the selected Person object so I  
can operate on it.


I know I could use the  -selection method of the NSController to get  
a proxy object, and then use -valueForKey: and -setValueForKey to  
operate on the object via the proxy. However, this puts the logic of  
the manipulations in my appController. I'd rather the collection of  
manipulations be in the Person class,  (i.e., have instance methods  
in the Person class that update a person object).


If I do this (have the update logic in the Person class),  then I  
can't use the proxy object returned by the -selection method of the  
NSController (because the proxy object doesn't respond to the  
methods of the backing class).


Have you considered binding the button's target to the array  
controller's selection, and putting the action methods on the Person  
directly?  (You might need to use a model key path of self to get  
around the proxy-ness.)


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: Garbage Collection woes...

2008-06-29 Thread j o a r


On Jun 27, 2008, at 12:31 PM, John Engelhart wrote:

Lesson #1:  If you have any interest in performance, you must avoid,  
at all costs, writing to a __strong pointer.



That's almost like saying:

	If you have any interest in performance, you must avoid, at all  
costs, using a high level language like C.


It's only true if you ignore other things that are also both true, and  
that many consider to have a higher priority. For one, using higher  
level languages and libraries allows us to be more productive and to  
build software that delivers more functionality while at the same time  
being easier to maintain.




-(BOOL)doSomething:(id)obj error:(NSError **)error
{
 if(error != NULL) { *error = NULL; } // Make sure we clear the  
error object

}

It's sort of ambiguous as to what should be returned by the indirect  
error pointer on the condition of success.  I could think of several  
neat ideas if the expected behavior were defined up front, even  
requiring the caller to initialize the pointer to a default NSError  
singleton and allowing errors to accumulate in a stack like  
fashion.  Alas, the only clearly defined behavior is that one  
failure, a NSError object is indirectly returned.



The relevant documentation is found here:

http://developer.apple.com/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/chapter_4_section_4.html#//apple_ref/doc/uid/TP40001806-CH204-SW5 



If you have suggestions for improvements, please file formal  
enhancement requests.



The write barrier penalty is substantial.  I benchmarked a tight  
loop that called a function that did nothing but the naive clearing  
of the value.  The result (on a 1.5GHz G4) was that it was 2429.55%  
(or, over 24 times) slower with -fobjc-gc enabled.  So, best to  
avoid updating a __strong pointer at any and all costs.



If you're a developer who cares about performance, your #1 priority is  
to implement the actual functionality. Your #2 priority to run  
meaningful benchmarks. Your #3 priority to address any performance  
problems that you find, in order of severity.


Synthetic / micro benchmarks are typically of limited value. Most  
Cocoa application developers will find that their performance problems  
are higher level and more algorithmic in nature, rather than on this  
very low level.




typedef struct {
 NSString *aString;
 __weak NSString *aWeakString;
 NSInteger anInteger;
} MYStructType;

MYStructType globalStructTypeArray[42]; // -- Global!

snip
The pointer to 'aString' in the above (or any of my other __strong  
pointers in my actual code) were clearly not being treated as  
__strong, and the GC system was reclaiming them causing all sorts of  
fun and random crashes.




Bugs are bad, and if you think that you have found one, it would be  
great if you could file a formal bug report.
That said, this is Cocoa-Dev, and the code above has very little to do  
with Cocoa / Objective-C development in practice.
Most Cocoa developers will find that Garbage Collection works  
absolutely fine, and that runtime performance is about the same  
(sometimes better, sometimes worse) compared with using manual memory  
management.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: mutableArrayForKeyValue Question (ignore other email)

2008-06-29 Thread Ken Thomases

On Jun 28, 2008, at 9:42 PM, Alex Wait wrote:

I am trying to modify the array controller programmatically and I'm  
running

into problems using mutableArrayForKeyValue

I am using this line

   id proxy = [controller mutableArrayValueForKey:@Person];


-mutableArrayValueForKey: is for modifying the model, not the  
controller (neither mediating nor coordinating).


I presume the code you're writing is part of the implementation of a  
coordinating controller, in which case you should have direct access  
to the model, so you shouldn't need to go back out to a mediating  
controller.


On the other hand, if you're writing a bindable view, then you can use  
-[NSArrayController addObjects:] or some other method on the mediating  
controller.


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: NSURLConnection vs CF and other ideas

2008-06-29 Thread Lukhnos D. Liu

On Jun 29, 2008, at 9:11 AM, Alex Kac wrote:
I've got a working HTTP Post with file upload using NSURLConnection,  
but I don't seem to see any ways to get progress on the upload  
beyond the connectionDidFinishLoading: delegate. Is
there a better way to be able to get progress info so we can display  
that to the user?


You might want to check out CFNetwork Programming Guide and CFHTTP  
request. You might want to try this too:http://objectiveflickr.googlecode.com/svn/trunk/Source/ 
 . It's an Objective-C wrapper of the CF layer and reports the  
progress to its delegate, among other things. Hope this helps.


d.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSExpression

2008-06-29 Thread mmalc crawford


On Jun 28, 2008, at 10:35 PM, Chris wrote:
NSExpression * ex = [NSExpression expressionForFunction: 
[NSExpression expressionForConstantValue:@BAR]  
selectorName:@length arguments:nil];

NSPredicate * predicate = [NSCompoundPredicate
   andPredicateWithSubpredicates:[NSArray arrayWithObject: ex]];
[predicate evaluateWithObject:@FOO substitutionVariables:nil];


What are you trying to achieve?
ex is not a predicate, so you're only supplying one -- incorrect --  
argument to create an AND predicate.  It's not clear what role FOO  
plays in the third line.


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSExpression

2008-06-29 Thread Nathan Kinsinger


On Jun 28, 2008, at 11:35 PM, Chris wrote:



If anyone has a clue how to use it, I'd be grateful. This was my  
unsuccessful attempt:


NSExpression * ex = [NSExpression expressionForFunction: 
[NSExpression expressionForConstantValue:@BAR]  
selectorName:@length arguments:nil];


NSPredicate * predicate = [NSCompoundPredicate
   andPredicateWithSubpredicates:[NSArray arrayWithObject: ex]];

[predicate evaluateWithObject:@FOO substitutionVariables:nil];

[NSFunctionExpression evaluateWithObject:substitutionVariables:]:  
unrecognized selector sent to instance 0x68b8af0


1) If you want to evaluate the NSExpression then use  
expressionValueWithObject:context.


	NSExpression * ex = [NSExpression expressionForFunction:[NSExpression  
expressionForConstantValue:@BAR] selectorName:@length  
arguments:nil];

int result = (int)[ex expressionValueWithObject:nil context:nil];

but this is probably not what you were trying to do (you didn't say  
what you were trying to do so I'm guessing). This is also a rather  
long way to get the length of a string.


2) andPredicateWithSubpredicates: wants an array of NSPredicates not  
NSExpressions.  When you evaluated the NSPredicate the NSExpression  
object you put in the subpredicate array does not implement  
evaluateWithObject:substitutionVariables: and you get that warning.  
(Note: NSFunctionExpression is a subclass of NSExpression created for  
expressions of type NSFunctionExpressionType)


I'm going to guess that you want to use a predicate to check the  
length of one string to the length of several others?


One way using a NSPredicate could be:

NSString *bar = [NSString stringWithString:@BAR];
NSString *foo = [NSString stringWithString:@FOO];
NSString *foobar = [NSString stringWithString:@FOOBAR];

	NSPredicate *predicate = [NSPredicate predicateWithFormat:@length ==  
%d, [bar length]];


BOOL result1 = [predicate evaluateWithObject:foo];
NSLog(@%@ = %@, foo, result1 ? @YES : @NO);

BOOL result2 = [predicate evaluateWithObject:foobar];
NSLog(@%@ = %@, foobar, result2 ? @YES : @NO);

output:
2008-06-29 02:23:23.475 testStrings[68040:10b] FOO = YES
2008-06-29 02:23:23.485 testStrings[68040:10b] FOOBAR = NO

There are easier ways to compare the lengths (just use the length  
method in an if statement).


If this does not cover what you are trying to do then you need to give  
more info.

--Nathan

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 converting a Carbon nib to Cocoa?

2008-06-29 Thread Fosse
My Carbon nib contains a lot of dialogs.  I want to make it be used by
another cocoa application and don't want to create all those dialogs and
econstruct the entire control hierarchy manually in the Interface Builder. I
don't care about connections, I'll wire them up myself. I'm just hoping to
avoid repeating the layout work.

The Cocoa nib uses binary file objects.nib which is different with the xml
file used byCarbon nib . I can't find any way to convert it with either
Interface Builder or nibtool.

Does anyone know of an automated method for doing the conversion?  Or method
to create Cocoa NIB without using Interface Builder?

I found two related questions here but no more answers..
http://lists.apple.com/archives/cocoa-dev/2001/Jul/msg00243.html
http://lists.apple.com/archives/carbon-development/2003/Aug/msg00161.html

Thanks a lot!
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 deal with a MenuItem with both a binded state property and an action method

2008-06-29 Thread Joan Lluch (casa)


El 28/06/2008, a las 18:44, Keary Suska escribió:


6/28/08 8:54 AM, also sprach [EMAIL PROTECTED]:


To sumarize, the problem is that I am not able to change the menuItem
state programatically (ie. in myAction) without avoiding the second
call to setMenuState. However if the call to myAction comes from a
button set up in IB (instead the menuItem), then everything goes ok.
In that case myAction is called by the click of the button and if the
state of the menuItem is updated by myAction then it is correctly
changed. No second call to setMenuState is received because the
originating event came from the button. On the contrary if the event
originates from the menuItem, first myAction is called, and then
setMenuState is called.


With controls, the bound value is changed *before* the target-action  
is
called, as you are seeing, but it seems NSMenuItem does the  
opposite. If the
calls are sequential--i.e. without a call to the run loop--you could  
use

performSelector:withObject:afterDelay:to make the setMenuState call.


Thanks, I am not absolutely sure because I did several changes in my  
project but I think that this can be considered a bug of 10.5 sdk,  
because it started to happen when I  started to compile for it. The  
(almost) same project when it was targeted for Tiger always changed  
the bound value *before* the target-action was executed, regardless if  
it was a button or a menuItem. Apparently this consistency has been  
broken in Leopard. I may post a bug report after some testing to  
confirm it.


Joan Lluch.___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Style Question

2008-06-29 Thread Hamish Allan
On Sat, Jun 28, 2008 at 6:15 AM, Alex Wait [EMAIL PROTECTED] wrote:

 I was meaning to imply that if it was called FirstName would setFirstName
 still be called?

See the first word of Jens' reply. But more importantly, just as Jens
says, unask the question :)

Hamish
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: XML-RPC Cocoa Parsing

2008-06-29 Thread Jens Alfke


On 28 Jun '08, at 10:24 PM, Rick Langschultz wrote:

I am trying to use XML-RPC for my data access on a web server  
(HTTPS). I wanted to know if parsing the XML-RPC data can be handled  
using NSXMLDocument and parsing the member, struct, name,  
value XML-RPC tags.


Sure. It'll parse any sort of valid XML.

Also, initWithContentsOfURL doesn't seem to fit that well... Should  
I use initWithXMLString?


-initWithData: would be better, as that gives it a chance to interpret  
the character encoding itself.


I am using the XMLRPCCall.h,m XMLRPCRequest.h,m and  
XMLRPCResponse.h,m classes, also with CURLHandle.framework...


I'm not familiar with that framework, but if it already provides an  
XML-RPC API, why do you need to parse the XML yourself?


—Jens___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURLConnection vs CF and other ideas

2008-06-29 Thread Jens Alfke


On 28 Jun '08, at 6:11 PM, Alex Kac wrote:

I've got a working HTTP Post with file upload using NSURLConnection,  
but I don't seem to see any ways to get progress on the upload  
beyond the connectionDidFinishLoading: delegate. Is there a better  
way to be able to get progress info so we can display that to the  
user?


Set the body of the request to an NSInputStream on the file. (This is  
a good idea anyway because it avoids having to load the entire file  
into memory.) Then you can periodically access the stream's  
NSStreamFileCurrentOffsetKey property (i.e. from a timer) to find out  
how much of the file has been read.


—Jens___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURLConnection vs CF and other ideas

2008-06-29 Thread Alex Kac
Perfect. I was reading about things like subclassing NSInputStream and  
having to implement methods for which no docs were available on what  
to implement and things like that. It sounds like its a lot simpler  
and so that's good. Will do!


On Jun 29, 2008, at 8:53 AM, Jens Alfke wrote:



On 28 Jun '08, at 6:11 PM, Alex Kac wrote:

I've got a working HTTP Post with file upload using  
NSURLConnection, but I don't seem to see any ways to get progress  
on the upload beyond the connectionDidFinishLoading: delegate. Is  
there a better way to be able to get progress info so we can  
display that to the user?


Set the body of the request to an NSInputStream on the file. (This  
is a good idea anyway because it avoids having to load the entire  
file into memory.) Then you can periodically access the stream's  
NSStreamFileCurrentOffsetKey property (i.e. from a timer) to find  
out how much of the file has been read.


—Jens


Alex Kac - President and Founder
Web Information Solutions, Inc. -  Central Texas Microsoft Certified  
Partner


It is useless for sheep to pass a resolution in favor of  
vegetarianism while wolves remain of a different opinion.

-- William Randolph Inge




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSURLConnection vs CF and other ideas

2008-06-29 Thread Alex Kac
Now that's very very nice as well. I actually did read the CFNetwork  
programming guide and CFHTTP request, but it seemed to me a lot more  
work for just the progress, but I was going to go that route when I  
decided to look it up in the mailing list archives. That's what made  
me ask because it *seemed* like it was possible with NSURLConnection  
based on some conversation snippets, but the whole conversations were  
not in the archive.


Thanks!

On Jun 29, 2008, at 2:07 AM, Lukhnos D. Liu wrote:


On Jun 29, 2008, at 9:11 AM, Alex Kac wrote:
I've got a working HTTP Post with file upload using  
NSURLConnection, but I don't seem to see any ways to get progress  
on the upload beyond the connectionDidFinishLoading: delegate. Is
there a better way to be able to get progress info so we can  
display that to the user?


You might want to check out CFNetwork Programming Guide and CFHTTP  
request. You might want to try this too:http://objectiveflickr.googlecode.com/svn/trunk/Source/ 
 . It's an Objective-C wrapper of the CF layer and reports the  
progress to its delegate, among other things. Hope this helps.


d.


Alex Kac - President and Founder
Web Information Solutions, Inc. -  Central Texas Microsoft Certified  
Partner


The optimist proclaims that we live in the best of all possible  
worlds; and the pessimist fears this is true.

-- James Clabell



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Using isMemberOfClass with a tree of subclass of NSManagedObject

2008-06-29 Thread Yoann GINI

Okey, I've solve the problem !

It's very simple, I've only load the in NSManagedObjectModel the mom  
file represent the modification base, not the main model... Now I load  
all mom file and it's work !


Thanks all

Le 29 juin 08 à 01:27, Bill Bumgarner a écrit :


On Jun 28, 2008, at 1:08 PM, Kyle Sluder wrote:

On Sat, Jun 28, 2008 at 2:14 PM, Bill Bumgarner [EMAIL PROTECTED] wrote:

You want -objectForKey:  -valueForKey: is for key value coding,
-objectForKey: is for extracting objects from a dictionary.

Shouldn't cause a problem.


I thought the collection classes were smart and treated -valueForKey:
by sending each object in the collection -valueForKey: and compiling
the results in an object arranged in the same way as the original.
That way you could have an array of strings and do something like
[myArray valueForKey:@length] to get an array of lengths
corresponding to each instance.


Sort of.  Depends on the collection class.  The behavior you  
describe works for NSArray (and NSSet, IIRC).  For NSDictionary, the  
rules are slightly different:

...

If key does not start with [EMAIL PROTECTED], invokes objectForKey:. If key does  
start with [EMAIL PROTECTED], strips the [EMAIL PROTECTED] and invokes [super valueForKey:]with  
the rest of the key.


...


Which is, frankly, a bit goofy and, thus, the primary reason why I  
would avoid using -valueForKey: on a dictionary.


b.bum


___

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

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

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

This email sent to [EMAIL PROTECTED]


Widgets for HUD

2008-06-29 Thread Erik Verbruggen
I know this has been asked before on this list (somewhere earlier this  
year), but I couldn't find the posting back. So sorry for repeating  
the question, but I'd like to use the HUD of Leopard and with  
fitting widgets. Somebody mentioned something on tweaking the look/ 
colours and somebody else mentioned a 3th party widget set. Can  
somebody point me to that widget set or to best practices around this  
topic?


Thanks,
Erik.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Widgets for HUD

2008-06-29 Thread Jonathan Dann


On 27 Jun 2008, at 20:48, Erik Verbruggen wrote:

I know this has been asked before on this list (somewhere earlier  
this year), but I couldn't find the posting back. So sorry for  
repeating the question, but I'd like to use the HUD of Leopard and  
with fitting widgets. Somebody mentioned something on tweaking the  
look/colours and somebody else mentioned a 3th party widget set. Can  
somebody point me to that widget set or to best practices around  
this topic?


Thanks,
Erik.


There's a great framework which is being made into a IB plugin. Its  
called BGHUDAppKit


Look here
www.binarymethod.com

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Methods that return autoreleased objects?

2008-06-29 Thread Charles Srstka

On Jun 29, 2008, at 1:58 AM, mmalc crawford wrote:


On Jun 28, 2008, at 9:59 PM, Charles Srstka wrote:

Methods that begin with alloc or new or contain copy will  
return objects you are responsible for. All other objects returned  
from methods are taken care of.


Well, there is the notable exception of top-level objects loaded  
from a NIB file, which do need to be released.



... which is documented:
	http://developer.apple.com/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_3.html# 



mmalc


Yes, but it's not obvious, which is why I thought to point it out  
since we're discussing the times when you should and shouldn't release  
objects. The alloc, init, and retain methods are also documented, but  
that doesn't mean we can't help people out with them, does it? I just  
think that the standard release something only if you inited or  
retained it advice should be amended to release something only if  
you inited or retained it, or if you got it from a NIB.


I know this confused *me* back when I was starting out, so I just  
thought I'd throw that out there.


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


[ANN] Amber.framework, shared source repository

2008-06-29 Thread Keith Duncan
I've made my shared source repository public, feel free to have a look  
at it code.google.com/p/amber-framework


It is a general purpose framework, i.e. it doesn't address a specific  
need; it consists mainly of categories and a handful of classes. There  
is little in the way of documentation but that is something I'm  
working on.


Keith Duncan
[EMAIL PROTECTED], 33software.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: Methods that return autoreleased objects?

2008-06-29 Thread mmalc crawford


On Jun 29, 2008, at 8:02 AM, Charles Srstka wrote:

Yes, but it's not obvious, which is why I thought to point it out  
since we're discussing the times when you should and shouldn't  
release objects. The alloc, init, and retain methods are also  
documented, but that doesn't mean we can't help people out with  
them, does it? I just think that the standard release something  
only if you inited or retained it advice should be amended to  
release something only if you inited or retained it, or if you got  
it from a NIB.


No, it shouldn't.  Because exactly what you do with objects you get  
from a nib depends on a number of factors.  The memory management  
guide itself has a complete article on the subject:
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemMgmtNibObjects.html 


which any Cocoa developer should have read as part of the fundamentals.

The basic memory management rules are simple and straightforward, and  
should be preserved as such -- simple and straightforward as they are  
they still seem to cause enough confusion.


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: noob questions regarding KVC accessors for a mutable array property

2008-06-29 Thread Stuart Malin
I do have the indexed accessors implemented. I also have an accessor  
that returns an array of the objects -- not sure why I did that...  
force of habit from other accessors (having a setter -setKey and a  
getter -Key).  I certainly can understand one reason why this  
wouldn't be good, because should some code somewhere acquire this  
immutable array, and hang on to it, then that list of objects could  
easily become out of sync.


That said, I instrumented my accessor and the index accessors to  
see what is being used.  Oddly (at least to me), if I do have the  
array-returning-accessor implemented, it is actually invoked by Cocoa  
code:  -[NSBinder  
_valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:]  Perhaps  
because the mutable array property is the content model for an  
NSArrayController, which has its arrangedObjects bound to a Table View.


I'm curious why, if it is advised to not have the -Key accessor,  
that Cocoa itself invokes the -Key accessor preferentially to the  
index accessors?



On Jun 26, 2008, at 9:49 PM, Scott Anguish wrote:

the better way is to implement the indexed accessors described in  
the KVC doc.


in fact I know at least one engineer would would like the doc to  
specifically say that you should NOT have an accessor that returns  
an array like this.



On Jun 26, 2008, at 7:54 PM, Stuart Malin wrote:

Separately, I have an accessor -attendees: of the Party class,  
which is currently implemented as:


- (NSArray*) attendees
{
	return [NSArray arrayWithArray:attendees];	// attendees is an  
NSMutableArray, and is an ivar

}

I intentionally do not return the underlying mutable array,  
because I don't want other code accessing the content without  
going through the accessors.


Is my implementation reasonable? Or are there preferable ways to  
do this (such as to return a copy of the mutable array)?


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: noob question regarding proxy object returned by -selection method of NSArrayController

2008-06-29 Thread Stuart Malin


On Jun 29, 2008, at 12:07 AM, Ken Thomases wrote:


On Jun 28, 2008, at 12:43 PM, Stuart Malin wrote:

I have a button in the GUI that should cause various changes to  
the person selected in the table. In the method that is the target  
of the button's action, I need to get the selected Person object  
so I can operate on it.


I know I could use the  -selection method of the NSController to  
get a proxy object, and then use -valueForKey: and -setValueForKey  
to operate on the object via the proxy. However, this puts the  
logic of the manipulations in my appController. I'd rather the  
collection of manipulations be in the Person class,  (i.e., have  
instance methods in the Person class that update a person object).


If I do this (have the update logic in the Person class),  then I  
can't use the proxy object returned by the -selection method of  
the NSController (because the proxy object doesn't respond to the  
methods of the backing class).


Have you considered binding the button's target to the array  
controller's selection, and putting the action methods on the  
Person directly?


Yes, I see that can do that.  My problem is hypothetical -- just  
test code to get a working understanding of the dynamics.


(You might need to use a model key path of self to get around the  
proxy-ness.)


Yes -- Owen Yamauchi pointed out to me the use of self (though not as  
a part of a model key path).



On Jun 28, 2008, at 11:14 AM, Owen Yamauchi wrote:
How about [[controller selection] valueForKey:@self]? NSObject  
has a

-self method which just returns the receiver, and since the proxy
object must respond to the KVC query as if it were the underlying
object, you get the underlying object back.


I found this quite intriguing -- and wondered why the -self method  
worked when I couldn't invoke the instance method I'd made. So I  
tried Owen's approach, substituting my instance method (that adjusts  
several of the object's ivars) for self  in invoking -valueForKey  
on the proxy object -- lo and behold, it worked.  I guess this  
shouldn't really have surprised me -- after all, how can the KVC  
mechanism know if a method is a canonical accessor (rhetorically asked).


So long as no arguments need to be passed to the instance method, one  
can use -valueForKey on the proxy object to execute an arbitrary   
instance method (i.e., not a canonical getter accessor). But doing  
this seems wrong to me -- using the KVC mechanism in a way that it  
isn't intended.  I suspect I'll avoid using it, but am curious if  
this (using KVC to invoke non-canonical getter) is troublesome or not?



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: noob question regarding proxy object returned by -selection method of NSArrayController

2008-06-29 Thread Ken Thomases

On Jun 29, 2008, at 10:47 AM, Stuart Malin wrote:


On Jun 28, 2008, at 11:14 AM, Owen Yamauchi wrote:
How about [[controller selection] valueForKey:@self]? NSObject  
has a

-self method which just returns the receiver, and since the proxy
object must respond to the KVC query as if it were the underlying
object, you get the underlying object back.


I found this quite intriguing -- and wondered why the -self method  
worked when I couldn't invoke the instance method I'd made. So I  
tried Owen's approach, substituting my instance method (that adjusts  
several of the object's ivars) for self  in invoking -valueForKey  
on the proxy object -- lo and behold, it worked.  I guess this  
shouldn't really have surprised me -- after all, how can the KVC  
mechanism know if a method is a canonical accessor (rhetorically  
asked).


So long as no arguments need to be passed to the instance method,  
one can use -valueForKey on the proxy object to execute an  
arbitrary  instance method (i.e., not a canonical getter accessor).


You might get in trouble if its return type is void.  Who knows what - 
valueForKey: will do in that case?


But doing this seems wrong to me -- using the KVC mechanism in a  
way that it isn't intended.  I suspect I'll avoid using it, but am  
curious if this (using KVC to invoke non-canonical getter) is  
troublesome or not?


Well, it is certainly troublesome from the point of view of code  
clarity and comprehension.


From the point of view of what will happen, it's fairly well defined,  
so I don't think you're setting yourself up for the code to blow up.   
That is, the fact that it's working in your test is not just an  
unreliable fluke.


Still, your gut reaction is one I share.  Don't do it.

However, note that -self is in fact a perfectly fine getter.  I have  
no qualms about using that particular key via KVC.


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: Widgets for HUD

2008-06-29 Thread Marcelo Alves


On 27/06/2008, at 16:48, Erik Verbruggen wrote:

I know this has been asked before on this list (somewhere earlier  
this year), but I couldn't find the posting back. So sorry for  
repeating the question, but I'd like to use the HUD of Leopard and  
with fitting widgets. Somebody mentioned something on tweaking the  
look/colours and somebody else mentioned a 3th party widget set. Can  
somebody point me to that widget set or to best practices around  
this topic?


http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/chapter_18_section_6.html#//apple_ref/doc/uid/2961-SW24 



or look for transparent panels in Apple Human Interface Guidelines.

:: marcelo.alves
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Output of NSHTTPCookieStorage to NSTableView

2008-06-29 Thread Chris Purcell
Thank you for the reply.  I think right now the simplest would be to  
convert the cookies array to an array of NSStrings.  What would be the  
easiest way to do this?


Thank you!


On Jun 28, 2008, at 9:56 PM, Shawn Erickson wrote:

On Sat, Jun 28, 2008 at 9:46 PM, Chris Purcell [EMAIL PROTECTED] 
 wrote:

Hello,
Not sure where my problem is I've tried a few things and no  
success.  I am

trying to output NSHTTPCookieStorage *cookies array to a table view.
Whenever I call the objectValueForTableColumn:row method the app  
errors
out, but if I leave it out the app launches displaying the correct  
number of
rows with nothing in it (as expected since I left out the other  
method).


Here is the code to get the cookies array:

  NSHTTPCookieStorage* sharedCookieStorage = [NSHTTPCookieStorage
sharedHTTPCookieStorage];
  cookies = [sharedCookieStorage cookies] ;

Here is the code to output the data to the table view:

- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
  return [cookies count];
}


- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
  row:(int)row
{
  return [cookies objectAtIndex:row];
}


What type of NSCell do you have set for the column (looks like you
only have a single column)? It is a specialized NSCell subclass that
knows how to display an instance NSHTTPCookie? If not this isn't going
to work as coded.

NSHTTPCookie isn't a string, number, image, etc. so one of the
standard cell subclasses wont know what to do with it. You either need
a custom cell subclass that can display it the way you want it
displayed or you will have to convert the NSHTTPCookie instance into a
form that a standard cell can handle (maybe an NSString).

-Shawn


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Methods that return autoreleased objects?

2008-06-29 Thread Mike Ferris
Best thing to do about the top-level nib exception to the rule is to  
use NSWindowController or NSViewController to do your nib loading.   
These classes properly take responsibility for top-level objects of  
the nibs they load and then all you have to do is manage the lifetime  
of the controller object as you normally would.


And, as long as we're on the topic... who can name the only other  
exceptional case for the release only if you alloc,new, copy or  
retain rule?  (It's pretty old-school...)


Mike Ferris

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Handling framework exceptions/errors?

2008-06-29 Thread David Troy

Hey folks,

I am fairly new to Cocoa development, so bear with me.

I have a situation where I am loading arbitray data from network- 
supplied URLs.  Sometimes the URLs contain Kanji unicode characters.   
When they do, my HTTP loading mechanism (which is built around NSURL*  
frameworks) dies with an exception deep inside of CFURLGetString.


Short of writing code to protect CFURLGetString from ever seeing one  
of these URLs, I thought the simplest thing to do would be to try to  
cover this section of code with a @try/@catch construct, but it seems  
to be having no effect.  The program still crashes.  I gather it is  
because what I'm getting is a null pointer type of issue, rather than  
something that generates a manageable NSException object.


Anyway, that all said, I'm just speculating.  Any actual info on  
solving this problem would be appreciated.


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]


DnD in NSMatrix

2008-06-29 Thread Micha Fuhrmann

Dear all,

I'm subclassing NSMatrix to enable DnD in a 10.4 NSBrowser. The  
dragout is fine, but I'm having trouble registering for drag ins. From  
my understanding I need to need to call -registerForDraggedTypes: in  
the NSMatrix's -initWithFrame:  subclass method


The trouble is I cannot access the initWithFrame method of my NSMatrix  
subclass. If I add the method it seems the parent NSMatrix class  
initWithFrame seems to get called, but not my NSMatrixSubClass  
initWithFrame.


I know this is a very basic Objective C question, I'm sorry for my  
ignorance.


Micha
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Cocoa Text System: How to determine the caret position?

2008-06-29 Thread Mike Ferris
I know that text along a path was done by someone in the past.   
Basically the strategy was:


	- let the text system lay out the text on a straight baseline (one  
long line)

- do the glyph drawing on your own along your path

Of course, spacing needs to be tightened/loosened depending on the  
curvature at the display point, for best results.


But at least you let the NSLayoutManager do the heavy lifting of  
getting the basic layout right.


This approach would also be more complicated if you needed to provide  
editing in-place of the text along the path.


As Doug says, vertical text is a bigger problem if you mean it in the  
sense of scripts that are traditionally written top to bottom.


Mike Ferris

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Clock-like looping

2008-06-29 Thread Ashley Perrien
Is there a fairly simple way of setting up a clock style looping of  
numbers? Where 1-12 act normally but 11 + 2 would return 1 and so on.  
I'm not doing time and would be dealing with ranges from 1 to 96, 77,  
120, that type of range. Would also need to be able to handle partial  
numbers (4.125 for instance). Any tips on where to look or is it just  
a lot of manual checking to make sure the number are within the  
correct range?


Ashley
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Clock-like looping

2008-06-29 Thread Daniel Richman

Use

double newNumber = oldNumber % 13;

This will return your number's remainder when dividing between 13, which 
could be 0 - 12.


Daniel


Ashley Perrien wrote:
Is there a fairly simple way of setting up a clock style looping of 
numbers? Where 1-12 act normally but 11 + 2 would return 1 and so on. 
I'm not doing time and would be dealing with ranges from 1 to 96, 77, 
120, that type of range. Would also need to be able to handle partial 
numbers (4.125 for instance). Any tips on where to look or is it just 
a lot of manual checking to make sure the number are within the 
correct range?


Ashley
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/applemaillist%40mm.danielrichman.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: Clock-like looping

2008-06-29 Thread Daniel Richman
Sorry, I just realized that won't work for floating point numbers. But 
you can check if the number is an integer first, then use the % operand 
if so.


Daniel


Daniel Richman wrote:

Use

double newNumber = oldNumber % 13;

This will return your number's remainder when dividing between 13, 
which could be 0 - 12.


Daniel


Ashley Perrien wrote:
Is there a fairly simple way of setting up a clock style looping of 
numbers? Where 1-12 act normally but 11 + 2 would return 1 and so on. 
I'm not doing time and would be dealing with ranges from 1 to 96, 77, 
120, that type of range. Would also need to be able to handle partial 
numbers (4.125 for instance). Any tips on where to look or is it just 
a lot of manual checking to make sure the number are within the 
correct range?


Ashley
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/applemaillist%40mm.danielrichman.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/applemaillist%40mm.danielrichman.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: mutableArrayForKeyValue Question (ignore other email)

2008-06-29 Thread Stuart Malin


On Jun 29, 2008, at 7:05 AM, Scot t Anguish wrote:


From: Scott Anguish [EMAIL PROTECTED]
Subject: Re: mutableArrayForKeyValue Question (ignore other email)
To: Alex Wait [EMAIL PROTECTED]
Cc: cocoa-dev Cocoa-dev@lists.apple.com
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

I think there is still some clarification necessary.

what exactly are you trying to accomplish, rather than how you are
trying to do it?

would I be correct to guess that you want to create a new Person
object and add it to the array?

if so you need to create the object and add it to the array

id newObjectToAdd = [theArrayController newObject];
[theArrayController addObject:newObjectToAdd];


or you can programmatically create the Person object, and add it
directly to the datamodel using, say

Person *aPerson=[[[Person alloc] init] autorelease];
and then add that to the data model using the mutableArrayforKeyValue:



As I am playing around with the very same concepts now, I tried these  
two approaches in my code, and get (slightly) different results.


When using the controller to add the Person object, the added object  
is NOT initialized.  My Person class's -init method sets initial  
values for its ivar properties. When I create an explicit instance of  
aPerson, and add that to the model, the values are shown in the view 
(s).  However, when I use the controller to add a new object, the  
ivars are not initialized.


Am I doing something wrong? Or is this is known artifact of using the  
controller as an intermediary to add an new instance?


~~~

Separately, there's another way to add an explicitly created Person  
to the data model -- using the index accessors, such as:
	[mutableArrayModel insertObject:aPerson inKeyAtIndex: 
[mutableArrayModel countOfKey]];


Actually, in my case, I made an instance method in the model class  
that adds a new person:  -(void) addKey:(Person*)aPerson that  
invokes the above referenced index accessors on self to add the new  
person to the Key property.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Clock-like looping

2008-06-29 Thread Sherm Pendley
On Sun, Jun 29, 2008 at 1:39 PM, Daniel Richman
[EMAIL PROTECTED] wrote:
 Sorry, I just realized that won't work for floating point numbers. But you
 can check if the number is an integer first, then use the % operand if so.

For floating-point modulus, one can use fmod(), fmodl(), or fmodf(),
for double, long double, or float, respectively.

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]


Re: Handling framework exceptions/errors?

2008-06-29 Thread Owen Yamauchi
On Sun, Jun 29, 2008 at 9:56 AM, David Troy [EMAIL PROTECTED] wrote:
 I have a situation where I am loading arbitray data from network-supplied
 URLs.  Sometimes the URLs contain Kanji unicode characters.  When they do,
 my HTTP loading mechanism (which is built around NSURL* frameworks) dies
 with an exception deep inside of CFURLGetString.

This sounds like it might be a bug, although I can't imagine no one's
tried this before.

 Short of writing code to protect CFURLGetString from ever seeing one of
 these URLs, I thought the simplest thing to do would be to try to cover this
 section of code with a @try/@catch construct, but it seems to be having no
 effect.  The program still crashes.  I gather it is because what I'm getting
 is a null pointer type of issue, rather than something that generates a
 manageable NSException object.

Yes. If the error message contains the word unhandled exception,
then you're getting an NSException. If you see the word SIGBUS or
SIGSEGV then there's a bad pointer somewhere. However, the issue
you're describing doesn't sound like it would be generating an
NSException. I have no experience with URLs containing characters
beyond 0x7F, so I can't help you much beyond that.

Owen
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: noob questions regarding KVC accessors for a mutable array property

2008-06-29 Thread Clark Cox
On Sun, Jun 29, 2008 at 8:33 AM, Stuart Malin [EMAIL PROTECTED] wrote:
 I do have the indexed accessors implemented. I also have an accessor that
 returns an array of the objects -- not sure why I did that... force of habit
 from other accessors (having a setter -setKey and a getter -Key).  I
 certainly can understand one reason why this wouldn't be good, because
 should some code somewhere acquire this immutable array, and hang on to it,
 then that list of objects could easily become out of sync.

 That said, I instrumented my accessor and the index accessors to see what
 is being used.  Oddly (at least to me), if I do have the
 array-returning-accessor implemented, it is actually invoked by Cocoa code:
  -[NSBinder _valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:]
  Perhaps because the mutable array property is the content model for an
 NSArrayController, which has its arrangedObjects bound to a Table View.

 I'm curious why, if it is advised to not have the -Key accessor, that
 Cocoa itself invokes the -Key accessor preferentially to the index
 accessors?

There's nothing wrong with having the -Key accessor. The problem
comes from having the -setKey: accessor *without* also implementing
the indexed setters; in such a case *every* single modification to the
proxy array will end up calling setKey: which can get horribly
inefficient.





 On Jun 26, 2008, at 9:49 PM, Scott Anguish wrote:

 the better way is to implement the indexed accessors described in the KVC
 doc.

 in fact I know at least one engineer would would like the doc to
 specifically say that you should NOT have an accessor that returns an array
 like this.


 On Jun 26, 2008, at 7:54 PM, Stuart Malin wrote:

 Separately, I have an accessor -attendees: of the Party class, which is
 currently implemented as:

 - (NSArray*) attendees
 {
return [NSArray arrayWithArray:attendees];  // attendees is
 an NSMutableArray, and is an ivar
 }

 I intentionally do not return the underlying mutable array, because I
 don't want other code accessing the content without going through the
 accessors.

 Is my implementation reasonable? Or are there preferable ways to do this
 (such as to return a copy of the mutable array)?

 ___

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

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

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

 This email sent to [EMAIL PROTECTED]




-- 
Clark S. Cox III
[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]


objc_exception_throw

2008-06-29 Thread casa
By setting a Breakpoint at objc_exception_throw or [NSException raise]  
I am able to stop my program when (for example) an out of range  
exception is thrown. However the call stack trace on the debugger  
window or the 'bt' command only shows a single line. For example:


#0  0x9500d0d7 in objc_exception_throw ()

Why the call trace is not showing?, What I am missing? How can I see  
an actual backtrace of my code before the exception was raised?


Thank you for your help.

Joan Lluch
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 converting a Carbon nib to Cocoa?

2008-06-29 Thread Christopher Pavicich

Hi:

   There is no way to automatically convert a Carbon Interface  
Builder Document into a Cocoa Interface Builder Document.
   You are going to need to recreate all of your Carbon dialogues in  
Cocoa. By hand.


--Chris

On Jun 29, 2008, at 1:59 AM, Fosse wrote:


My Carbon nib contains a lot of dialogs.  I want to make it be used by
another cocoa application and don't want to create all those dialogs  
and
econstruct the entire control hierarchy manually in the Interface  
Builder. I
don't care about connections, I'll wire them up myself. I'm just  
hoping to

avoid repeating the layout work.

The Cocoa nib uses binary file objects.nib which is different with  
the xml
file used byCarbon nib . I can't find any way to convert it with  
either

Interface Builder or nibtool.

Does anyone know of an automated method for doing the conversion?   
Or method

to create Cocoa NIB without using Interface Builder?

I found two related questions here but no more answers..
http://lists.apple.com/archives/cocoa-dev/2001/Jul/msg00243.html
http://lists.apple.com/archives/carbon-development/2003/Aug/msg00161.html

Thanks a lot!
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/cmp%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: Output of NSHTTPCookieStorage to NSTableView

2008-06-29 Thread Jens Alfke


On 29 Jun '08, at 9:39 AM, Chris Purcell wrote:

Thank you for the reply.  I think right now the simplest would be to  
convert the cookies array to an array of NSStrings.  What would be  
the easiest way to do this?


Keep the array as an array of NSHTTPCookies. But your - 
objectValueForTableColumn: should look up the cookie object for the  
row, and then get the right attribute of the cookie based on the  
column identifier. For instance, if the column shows URLs, then you  
should get the URL of the cookie and return its absoluteString. If it  
shows dates, return an NSDate.


—Jens___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTextView to replace NSTextList confused

2008-06-29 Thread Papa-Raboon
Hi Kyle and thanks for responding. I am not sure what part of the
documentation you refer to when you say cocoa text system but I
started reading about NSTextView and NSText and to be honest until I
get more familiar with cocoa and everything clicks into place the
documentation seems very confusing and tends to assume previous
programming knowledge and a good understanding of the nuances of this
sort of code. I have dabbled with other languages but the only
language I managed to get a good understanding of was PHP. Cocoa seems
a lot more disciplined in it's structure to me than PHP which is very
forgiving indeed.

So at the moment people have been kindly telling me what to do to
achieve each little bit of my project that I don't understand and I
have been figuring out bits myself along the way. this method seems to
work best for me as I have started to figure out more and more without
help. So I think I understand what you mean about not using NSString
with an NSTextView but if you fancy throwing together a couple of
lines of code so I can see visually how it's done then I think I will
have a better chance of understanding it eventually.

If you don't have time to then I understand totally. I am sure newbies
like me can be a little demanding at times :-)

Thanks

Paul

2008/6/29 Kyle Sluder [EMAIL PROTECTED]:
 On Sat, Jun 28, 2008 at 8:28 PM, Papa-Raboon [EMAIL PROTECTED] wrote:
 So I did this and changed the header file for my mainController to
 take the NSTextView into consideration by changing:

 IBOutlet NSTextField* theNotes;

 to:

 IBOutlet NSTextView *theNotes;

 I then built and ran the project and surprise surprise it didn't work.
 In Xcode I get the following:
 warning 'NSTextView' may not respond to '-stringValue'
 (Messages without a matching method signature will be assumed to
 return 'id' and accept '...' as arguments.).

 Any ideas what I am doing wrong please anyone.

 Look at the documentation for NSTextView.  Notice how it doesn't
 implement -stringValue?  Neither do any of its superclasses.
 Therefore you can't send an NSTextView a -stringValue message and
 expect anything meaningful.  NSTextView does inherit from NSText,
 though, which responds to -string by returning the backing store.

 Do read the documentation for the Cocoa Text System.  NSTextView is
 different from (and far more powerful than) NSTextField.

 --Kyle Sluder

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Handling framework exceptions/errors?

2008-06-29 Thread Jens Alfke


On 29 Jun '08, at 9:56 AM, David Troy wrote:

I have a situation where I am loading arbitray data from network- 
supplied URLs.  Sometimes the URLs contain Kanji unicode  
characters.  When they do, my HTTP loading mechanism (which is built  
around NSURL* frameworks) dies with an exception deep inside of  
CFURLGetString.


That indicates either a bug in the frameworks, or that you're passing  
in illegal values.


Also, what do you mean by a URL containing Kanji characters? URLs can  
only contain ASCII; anything else should be escaped using %. If you  
try to construct an NSURL from an invalid string, you'll get nil, and  
passing that nil URL into other framework calls could definitely cause  
exceptions/crashes.


Pasting in the backtrace from a crash log would be useful for  
diagnosing this.


—Jens___

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

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

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

This email sent to [EMAIL PROTECTED]


Unicode in URLs (was Handling framework exceptions/errors?)

2008-06-29 Thread David Troy

Jens,

Thanks for the help.

I am being handed a URL as an NSString and am simply forwarding it to  
the frameworks for processing.


A example URL which causes a crash is:
http://foo.com/56033713/アイコン用ハング音_normal.jpg

(where foo.com is something else)

I didn't check to see if [NSURL URLWithString:url] is returning nil.   
If it is, I should of course be trapping that and not trying to create  
a request from it.


I am doing this:
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL: 
[NSURL URLWithString:url]

cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:timeout];

I was sort of under the impression that NSURL URLWithString: would  
deal with escaping/translating the Kanji characters, but I could see  
how it might not.


Is there some method I can use to break the Kanji back out into  
escaped characters before passing it to NSURL URLWithString: ?


Thanks!

Dave


On Jun 29, 2008, at 4:00 PM, Jens Alfke wrote:



On 29 Jun '08, at 9:56 AM, David Troy wrote:

I have a situation where I am loading arbitray data from network- 
supplied URLs.  Sometimes the URLs contain Kanji unicode  
characters.  When they do, my HTTP loading mechanism (which is  
built around NSURL* frameworks) dies with an exception deep inside  
of CFURLGetString.


That indicates either a bug in the frameworks, or that you're  
passing in illegal values.


Also, what do you mean by a URL containing Kanji characters? URLs  
can only contain ASCII; anything else should be escaped using %.  
If you try to construct an NSURL from an invalid string, you'll get  
nil, and passing that nil URL into other framework calls could  
definitely cause exceptions/crashes.


Pasting in the backtrace from a crash log would be useful for  
diagnosing this.


—Jens


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Handling framework exceptions/errors?

2008-06-29 Thread Sherm Pendley
On Sun, Jun 29, 2008 at 4:00 PM, Jens Alfke [EMAIL PROTECTED] wrote:

 Also, what do you mean by a URL containing Kanji characters?

I suppose he means one like this: http://例え.テスト - which works
correctly in Safari, btw.

 URLs can only contain ASCII

Not true. Have a look at: http://idn.icann.org

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]


Re: Handling framework exceptions/errors?

2008-06-29 Thread Jim Correia

On Jun 29, 2008, at 4:17 PM, Sherm Pendley wrote:

On Sun, Jun 29, 2008 at 4:00 PM, Jens Alfke [EMAIL PROTECTED]  
wrote:


Also, what do you mean by a URL containing Kanji characters?


I suppose he means one like this: http://例え.テスト -  
which works

correctly in Safari, btw.


Safari is encoding the non-ASCII characters before passing them down  
the to the networking stack.



URLs can only contain ASCII


Not true. Have a look at: http://idn.icann.org


NSURL's initWithString:relativeToBase: method is documented as  
requiring an RFC 2396 conformant URL, which means that all non-ASCII  
characters must be escaped.


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: Handling framework exceptions/errors?

2008-06-29 Thread Sherm Pendley
On Sun, Jun 29, 2008 at 12:56 PM, David Troy [EMAIL PROTECTED] wrote:

 I have a situation where I am loading arbitray data from network-supplied
 URLs.  Sometimes the URLs contain Kanji unicode characters.  When they do,
 my HTTP loading mechanism (which is built around NSURL* frameworks) dies
 with an exception deep inside of CFURLGetString.

I suspect that NSURL doesn't support IDN. There's a list of RFCs that
NSURL supports listed at the top of its reference page - I don't see
RFC3490 Internationalizing Domain Names in Applications listed
there. Although, such URLs *do* work in Safari.

You may have to do your own ToASCII conversion before creating the
NSURL object, as described in the RFC:

http://www.ietf.org/rfc/rfc3490.txt

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]


Is this still true?

2008-06-29 Thread Alex Wait
this page has been frequently linked to as helpful and it is! :)

http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

But does the bug it talks about still exist?

- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object change:(NSDictionary *)change context:(void
*)context
{
/*
Should be able to use
id oldValue = [change objectForKey:NSKeyValueChangeOldKey];
but the dictionary doesn't contain old and new values...
*/

The change dictionary doesn't contain old and new values. This is not your
fault, it's due to a bug in the controller. This bug will not be fixed in
the forseeable future.
--


-- 
If you can't be kind, at least have the decency to be vague.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Handling framework exceptions/errors?

2008-06-29 Thread Sherm Pendley
2008/6/29 Jim Correia [EMAIL PROTECTED]:
 On Jun 29, 2008, at 4:17 PM, Sherm Pendley wrote:

 On Sun, Jun 29, 2008 at 4:00 PM, Jens Alfke [EMAIL PROTECTED] wrote:

 URLs can only contain ASCII

 Not true. Have a look at: http://idn.icann.org

 NSURL's initWithString:relativeToBase: method is documented as requiring an
 RFC 2396 conformant URL, which means that all non-ASCII characters must be
 escaped.

True, but URLS can only contain ASCII, and NSURL doesn't support
RFC 3490 are entirely different statements. :-)

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]


viewing method calls

2008-06-29 Thread John Murphy
How do I view the messages (method calls) that are sent during the loading of 
an application?


  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Unicode in URLs (was Handling framework exceptions/errors?)

2008-06-29 Thread Stephen J. Butler
On Sun, Jun 29, 2008 at 3:10 PM, David Troy [EMAIL PROTECTED] wrote:
 I was sort of under the impression that NSURL URLWithString: would deal with
 escaping/translating the Kanji characters, but I could see how it might not.

 Is there some method I can use to break the Kanji back out into escaped
 characters before passing it to NSURL URLWithString: ?

The problem is that NSURL doesn't know what encoding scheme to use
when escaping the kanji. Most modern applications expect UTF-8, but
it's possible you need Japanese EUC or Shift_JIS. When you know what
encoding you want to use, pass the string through -[NSString
stringByAddingPercentEscapesUsingEncoding:].

But as someone else hinted, this doesn't fix japanese domain names.
There is, unfortunately, no built in support for punycode, and
-[NSString stringByAddingPercentEscapesUsingEncoding:] will completely
mug your hostname. In this case, you need a more complex scheme to
handle URL strings. Probably break apart the URL into its pieces,
encode the hostname and path separately, and then put it back together
with -[NSURL initWithScheme:host:path:].
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSTextView to replace NSTextList confused

2008-06-29 Thread Nathan Kinsinger


On Jun 29, 2008, at 1:58 PM, Papa-Raboon wrote:


Hi Kyle and thanks for responding. I am not sure what part of the
documentation you refer to when you say cocoa text system but I
started reading about NSTextView and NSText and to be honest until I
get more familiar with cocoa and everything clicks into place the
documentation seems very confusing and tends to assume previous
programming knowledge and a good understanding of the nuances of this
sort of code. I have dabbled with other languages but the only
language I managed to get a good understanding of was PHP. Cocoa seems
a lot more disciplined in it's structure to me than PHP which is very
forgiving indeed.

So at the moment people have been kindly telling me what to do to
achieve each little bit of my project that I don't understand and I
have been figuring out bits myself along the way. this method seems to
work best for me as I have started to figure out more and more without
help. So I think I understand what you mean about not using NSString
with an NSTextView but if you fancy throwing together a couple of
lines of code so I can see visually how it's done then I think I will
have a better chance of understanding it eventually.

If you don't have time to then I understand totally. I am sure newbies
like me can be a little demanding at times :-)

Thanks

Paul


If you look in the upper left corner of the NSTextView or NSText  
documentation page you will see a box labeled NSText[View] Class  
Reference, at the bottom of that box is a section labeled Companion  
Guide and in there is a link to Text System Overview, which is the  
doc that Kyle is referring to. You should probably read most of it,  
but especially read the Building a Text Editor in 15 Minutes chapter  
which has sample code that should do what you need or at least get you  
in the right direction.


If you are just learning Cocoa then you should really start with the  
Cocoa Fundamentals Guide:

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/chapter_1_section_1.html
or a Cocoa programming book.

--Nathan




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: description and proxy objects

2008-06-29 Thread Torsten Curdt

[[[accountsController selectedObjects] objectAtIndex:0] description];


Ah!


[[accountsController selection] valueForKey:@description];


Doh! ...of course :) So obvious.

Thanks, guys!

cheers
--
Torsten
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Is this still true?

2008-06-29 Thread Hamish Allan
On Sun, Jun 29, 2008 at 9:48 PM, Alex Wait [EMAIL PROTECTED] wrote:

 But does the bug it talks about still exist?

I'm afraid so. But what I really want to know is, *why* won't it be
fixed any time soon? I presume there *is* a reason, otherwise why
would mmalc make such a claim?

Hamish
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSTextView to replace NSTextList confused

2008-06-29 Thread Papa-Raboon
This is great, I changed the line that said:
myNotes = [theNotes stringValue];
to:
myNotes = [theNotes string];
And it worked.

I am not sure where abouts in the class reference for NSTextView it
states that you should pass it a -string rather than a -stringValue
but it worked all the same.

Brilliant

Thanks again
Paul

2008/6/29 Nathan Kinsinger [EMAIL PROTECTED]:

 On Jun 29, 2008, at 1:58 PM, Papa-Raboon wrote:

 Hi Kyle and thanks for responding. I am not sure what part of the
 documentation you refer to when you say cocoa text system but I
 started reading about NSTextView and NSText and to be honest until I
 get more familiar with cocoa and everything clicks into place the
 documentation seems very confusing and tends to assume previous
 programming knowledge and a good understanding of the nuances of this
 sort of code. I have dabbled with other languages but the only
 language I managed to get a good understanding of was PHP. Cocoa seems
 a lot more disciplined in it's structure to me than PHP which is very
 forgiving indeed.

 So at the moment people have been kindly telling me what to do to
 achieve each little bit of my project that I don't understand and I
 have been figuring out bits myself along the way. this method seems to
 work best for me as I have started to figure out more and more without
 help. So I think I understand what you mean about not using NSString
 with an NSTextView but if you fancy throwing together a couple of
 lines of code so I can see visually how it's done then I think I will
 have a better chance of understanding it eventually.

 If you don't have time to then I understand totally. I am sure newbies
 like me can be a little demanding at times :-)

 Thanks

 Paul

 If you look in the upper left corner of the NSTextView or NSText
 documentation page you will see a box labeled NSText[View] Class
 Reference, at the bottom of that box is a section labeled Companion Guide
 and in there is a link to Text System Overview, which is the doc that Kyle
 is referring to. You should probably read most of it, but especially read
 the Building a Text Editor in 15 Minutes chapter which has sample code
 that should do what you need or at least get you in the right direction.

 If you are just learning Cocoa then you should really start with the Cocoa
 Fundamentals Guide:
 http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/chapter_1_section_1.html
 or a Cocoa programming book.

 --Nathan





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSTextView to replace NSTextList confused

2008-06-29 Thread Nathan Kinsinger


On Jun 29, 2008, at 4:48 PM, Papa-Raboon wrote:


This is great, I changed the line that said:
myNotes = [theNotes stringValue];
to:
myNotes = [theNotes string];
And it worked.

I am not sure where abouts in the class reference for NSTextView it
states that you should pass it a -string rather than a -stringValue
but it worked all the same.

Brilliant

Thanks again
Paul



It's inherited from NSText. Remember to look at superclasses when  
looking for functionality.


Check out AppKiDo, it's an alternate browser for the Cocoa classes  
that can show all methods for a class, including the ones it inherits:

http://homepage.mac.com/aglee/downloads/appkido.html

--Nathan


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Thread safe reference counting

2008-06-29 Thread atebits
Perhaps I'm blind, but after pouring over every scrap of information I  
could find, I could not find the answer to this question.


Are -retain and -release thread-safe? (Perhaps as atomic increments/ 
decrements internally?)


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Thread safe reference counting

2008-06-29 Thread Chris Suter


On 30/06/2008, at 9:06 AM, atebits wrote:

Perhaps I'm blind, but after pouring over every scrap of information  
I could find, I could not find the answer to this question.


Are -retain and -release thread-safe? (Perhaps as atomic increments/ 
decrements internally?)


Yes, -retain and -release are thread-safe. It's in the documentation  
somewhere.


-- Chris



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]

Scrolling during zoom

2008-06-29 Thread James Maxwell

Hello All,

I've implemented a sort of time zoom for a music app I'm working on.  
Basically, it's just re-positioning objects along a musical staff when  
I click and drag up/down the screen (like in Live, or Logic...  
Soundtrack too, I think). However, if I'm in the middle of a score,  
the content I'm looking at quickly flies off the right side of window,  
because the zoom is obviously making time occupy more horizontal  
space, and shifting notes in the middle of the score off to the right.  
I'd basically just like to scroll the view in such a way as to keep  
the area of score I'm trying to zoom in on in view...

I'm sure it's not very complicated, but any help would be appreciated.

thanks,

J.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Is this still true?

2008-06-29 Thread Alex Wait
weird. I tried this:

[newPerson addObserver:observe forKeyPath:@lastName options:(
NSKeyValueObservingOptionOld| NSKeyValueObservingOptionNew) context:NULL];

and below is my method

NSLog(@observing);

//int oldLastName = [change o];
id oldName = [change objectForKey:NSKeyValueChangeOldKey];
id newName = [change objectForKey:NSKeyValueChangeNewKey];

NSLog(@old value was %@, oldName);
NSLog(@new value was %@, newName);

}


and sure enough I get both the new value and the old value. Am I shooting
past the problem?

On Sun, Jun 29, 2008 at 3:45 PM, Hamish Allan [EMAIL PROTECTED] wrote:

 On Sun, Jun 29, 2008 at 9:48 PM, Alex Wait [EMAIL PROTECTED] wrote:

  But does the bug it talks about still exist?

 I'm afraid so. But what I really want to know is, *why* won't it be
 fixed any time soon? I presume there *is* a reason, otherwise why
 would mmalc make such a claim?

 Hamish




-- 
If you can't be kind, at least have the decency to be vague.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Is this still true?

2008-06-29 Thread Scott Anguish
the controller classes don't return old and new values, that's the  
part that isn't implemented.


your own classes (provided they're written in a KVO compliant manner)  
will return both.



On Jun 29, 2008, at 7:32 PM, Alex Wait wrote:


weird. I tried this:

[newPerson addObserver:observe forKeyPath:@lastName options:(
NSKeyValueObservingOptionOld| NSKeyValueObservingOptionNew)  
context:NULL];


and below is my method

   NSLog(@observing);

   //int oldLastName = [change o];
   id oldName = [change objectForKey:NSKeyValueChangeOldKey];
   id newName = [change objectForKey:NSKeyValueChangeNewKey];

   NSLog(@old value was %@, oldName);
   NSLog(@new value was %@, newName);

}


and sure enough I get both the new value and the old value. Am I  
shooting

past the problem?

On Sun, Jun 29, 2008 at 3:45 PM, Hamish Allan [EMAIL PROTECTED]  
wrote:


On Sun, Jun 29, 2008 at 9:48 PM, Alex Wait [EMAIL PROTECTED]  
wrote:



But does the bug it talks about still exist?


I'm afraid so. But what I really want to know is, *why* won't it be
fixed any time soon? I presume there *is* a reason, otherwise why
would mmalc make such a claim?

Hamish





--
If you can't be kind, at least have the decency to be vague.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/scott%40cocoadoc.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: Is this still true?

2008-06-29 Thread Alex Wait
ah. I see.

I would still love to know why the apple devs haven't gotten around to do
this yet. :)

On Sun, Jun 29, 2008 at 4:37 PM, Scott Anguish [EMAIL PROTECTED] wrote:

 the controller classes don't return old and new values, that's the part
 that isn't implemented.

 your own classes (provided they're written in a KVO compliant manner) will
 return both.



 On Jun 29, 2008, at 7:32 PM, Alex Wait wrote:

  weird. I tried this:

 [newPerson addObserver:observe forKeyPath:@lastName options:(
 NSKeyValueObservingOptionOld| NSKeyValueObservingOptionNew) context:NULL];

 and below is my method

   NSLog(@observing);

   //int oldLastName = [change o];
   id oldName = [change objectForKey:NSKeyValueChangeOldKey];
   id newName = [change objectForKey:NSKeyValueChangeNewKey];

   NSLog(@old value was %@, oldName);
   NSLog(@new value was %@, newName);

 }


 and sure enough I get both the new value and the old value. Am I shooting
 past the problem?

 On Sun, Jun 29, 2008 at 3:45 PM, Hamish Allan [EMAIL PROTECTED] wrote:

  On Sun, Jun 29, 2008 at 9:48 PM, Alex Wait [EMAIL PROTECTED] wrote:

  But does the bug it talks about still exist?


 I'm afraid so. But what I really want to know is, *why* won't it be
 fixed any time soon? I presume there *is* a reason, otherwise why
 would mmalc make such a claim?

 Hamish




 --
 If you can't be kind, at least have the decency to be vague.
 ___

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

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

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

 This email sent to [EMAIL PROTECTED]





-- 
If you can't be kind, at least have the decency to be vague.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Scrolling during zoom

2008-06-29 Thread Graham Cox

Search the docs for -scrollRectToVisible: and -scrollToPoint:


G.

p.s. since I know you're doing this in DK, also look at DKDrawing's - 
scrollToRect: method, which you should use.



On 30 Jun 2008, at 9:17 am, James Maxwell wrote:


Hello All,

I've implemented a sort of time zoom for a music app I'm working  
on. Basically, it's just re-positioning objects along a musical  
staff when I click and drag up/down the screen (like in Live, or  
Logic... Soundtrack too, I think). However, if I'm in the middle of  
a score, the content I'm looking at quickly flies off the right side  
of window, because the zoom is obviously making time occupy more  
horizontal space, and shifting notes in the middle of the score off  
to the right. I'd basically just like to scroll the view in such a  
way as to keep the area of score I'm trying to zoom in on in view...

I'm sure it's not very complicated, but any help would be appreciated.

thanks,

J.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.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: Thread safe reference counting

2008-06-29 Thread Michael Ash
On Sun, Jun 29, 2008 at 7:12 PM, Chris Suter [EMAIL PROTECTED] wrote:

 On 30/06/2008, at 9:06 AM, atebits wrote:

 Perhaps I'm blind, but after pouring over every scrap of information I
 could find, I could not find the answer to this question.

 Are -retain and -release thread-safe? (Perhaps as atomic
 increments/decrements internally?)

 Yes, -retain and -release are thread-safe. It's in the documentation
 somewhere.

Here:

http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/chapter_950_section_2.html

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: Thread safe reference counting

2008-06-29 Thread atebits

Awesome, thanks.

I remember reading that page, just completely missed the Object  
allocation and retain count functions note in the list.


Loren

On Jun 29, 2008, at 5:30 PM, Michael Ash wrote:

On Sun, Jun 29, 2008 at 7:12 PM, Chris Suter [EMAIL PROTECTED]  
wrote:


On 30/06/2008, at 9:06 AM, atebits wrote:

Perhaps I'm blind, but after pouring over every scrap of  
information I

could find, I could not find the answer to this question.

Are -retain and -release thread-safe? (Perhaps as atomic
increments/decrements internally?)


Yes, -retain and -release are thread-safe. It's in the documentation
somewhere.


Here:

http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/chapter_950_section_2.html

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/loren.brichter%40atebits.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]


CALayer and View Scaling

2008-06-29 Thread Gordon Apple
Apparently, there is a disconnect between the view's coordinate system
context and that of the contained CALayers.  I'm using Sketch's
SKTZoomingScrollView to set the scale factor of my main drawing view.  It
works great without CALayers.  What is does is it scales the bounds of the
containing NSClipView, which automatically scales my main view.  However,
the CALayers don't scale when they draw in the view.

BTW, I tried unsuccessfully to observe the clip view's bounds to trigger
code to resize the CALayers.  Why can't I observe it?  I finally set an
observer on the scale factor in SKTZoomingScrollView.

What is the best way to make the CALayers track my main view?  The main
view is not really changed except for the fact that it is embedded in the
clip view which has rescaled its bounds.  Apparently, scaling the view
coordinates does not propagate down to the CALayers.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Is this still true?

2008-06-29 Thread Hamish Allan
On Mon, Jun 30, 2008 at 12:37 AM, Scott Anguish [EMAIL PROTECTED] wrote:

 the controller classes don't return old and new values, that's the part that
 isn't implemented.

 your own classes (provided they're written in a KVO compliant manner) will
 return both.

Unless their properties are bound to, or dependent upon, properties
with key paths involving those controller classes :(

If this single bug were fixed, bindings would pretty much fulfill
their promise to make event-driven programming in Cocoa a joy.
Instead, you'll find yourself constantly working around it and
wondering why Apple have failed to fix it these past five years.

Hamish
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Anybody here credited in Wall-E?

2008-06-29 Thread Robert Nicholson
In the past I've seen well known Cocoa programmers like Michael B  
Johnson and Mike Ferris in the Pixar credits. I caught Michael B  
Johnson's name in the credits but by the time they get to the software  
developers the list is just too large to follow.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: CALayer and View Scaling

2008-06-29 Thread Graham Cox
I'm not familiar with SKTZoomingScrollView but I do wonder why its  
author wrote it that way, when to get zooming you can simply use the  
actual view's -scaleUnitSquareToSize: method (plus frame computation),  
and any enclosing clipview/scrollview does the right thing without any  
work at all. I thought that was the supported way to implement  
zooming, so maybe CALayer will work when zooming is done that way.


If there's some good reason NOT to use -scaleUnitSquareToSize: I'd  
like to hear it because that's what I've been using since 10.2 and  
have had no problem with it.


I have a general-purpose view class here that wraps up this zoom  
functionality. Might we worth trying with CALayer...


http://apptree.net/gczoomview.htm


cheers, Graham


On 30 Jun 2008, at 1:25 pm, Gordon Apple wrote:

   Apparently, there is a disconnect between the view's coordinate  
system

context and that of the contained CALayers.  I'm using Sketch's
SKTZoomingScrollView to set the scale factor of my main drawing  
view.  It
works great without CALayers.  What is does is it scales the bounds  
of the
containing NSClipView, which automatically scales my main view.   
However,

the CALayers don't scale when they draw in the view.

   BTW, I tried unsuccessfully to observe the clip view's bounds to  
trigger
code to resize the CALayers.  Why can't I observe it?  I finally set  
an

observer on the scale factor in SKTZoomingScrollView.

   What is the best way to make the CALayers track my main view?   
The main
view is not really changed except for the fact that it is embedded  
in the

clip view which has rescaled its bounds.  Apparently, scaling the view
coordinates does not propagate down to the CALayers.

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.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: Why aren't my bindings firing?

2008-06-29 Thread Hamish Allan
On Sat, Jun 28, 2008 at 4:17 PM, Charles Srstka
[EMAIL PROTECTED] wrote:

 I wouldn't worry about that too much - everything you said seems to jibe
 perfectly with what views do - the text field's binding *is* called value
 and not stringValue (that was my bad), and there's no corresponding
 value instance method on NSTextView nor any of its superclasses, nor does
 running class-dump on the AppKit turn up a value method on any class in
 the AppKit except for _NSControllerKeyValuePair, whatever that is. So in the
 typical case of views, you'd seem to be correct that the bindings represent
 something other than properties, and live in a different namespace.

And if you consider the relationship between the value binding and
the objectValue property, things get even more odd!

You can programmatically bind to an NSTextField's (and presumably any
other NSControl's) objectValue and achieve the same results as
binding to its value (either programmatically or through IB).

So you might think that NSControl has a value property, and simply
binds it to its own objectValue (or vice versa). Except that you
can't call setValue (or setValue:whatever forKey:@value) on an
NSControl, as you would expect to be able to if this were the case.

Perhaps NSControls have their own bind:toObject:withKeyPath:options:
implementation which simply checks for value and effectively binds
to objectValue? No, classdump confirms that the only
bind:toObject:withKeyPath:options: implementation is that of the
NSKeyValueBindingCreation category of NSObject.

Maybe it's the NSObject implementation itself which handles the
special case? No, you can create an objectValue property on your own
classes but you still can't bind to value on them (the error message
complains this class is not key value coding-compliant for the key
value)

It seems really wierd to me that this separate namespace exists,
especially as the AppKit designers could just have exposed the
objectValue binding directly rather than this value binding which
seems to do exactly the same thing...

Hamish
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why aren't my bindings firing?

2008-06-29 Thread Charles Srstka

On Jun 29, 2008, at 11:30 PM, Hamish Allan wrote:


Perhaps NSControls have their own bind:toObject:withKeyPath:options:
implementation which simply checks for value and effectively binds
to objectValue? No, classdump confirms that the only
bind:toObject:withKeyPath:options: implementation is that of the
NSKeyValueBindingCreation category of NSObject.


Wait, what? Okay, that contradicts the understanding that I had come  
to... so the built-in views establish two-way bindings *without*  
overriding bind:toObject:withKeyPath:options:? Great, that puts us  
back to square one!


Is there some way to page mmalc to this thread? I think his input  
would be really helpful about now...


Charles
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why aren't my bindings firing?

2008-06-29 Thread Hamish Allan
On Mon, Jun 30, 2008 at 5:33 AM, Charles Srstka
[EMAIL PROTECTED] wrote:

 Wait, what? Okay, that contradicts the understanding that I had come to...
 so the built-in views establish two-way bindings *without* overriding
 bind:toObject:withKeyPath:options:? Great, that puts us back to square one!

It would seem so, but in fact I was mistaken about the equivalence
between value and objectValue bindings: the binding to objectValue
is only a one-way binding. I guess that difference would make it safer
to use a separate namespace.

Hamish
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Output of NSHTTPCookieStorage to NSTableView

2008-06-29 Thread Chris Purcell
Thank you for the reply.  I am a bit of a Cocoa newbie and I'm having  
trouble using the objectValueForTableColumn:.  My NSTableView is only  
one column, but I would like to display all attributes of each key.


This is an example of what is outputting when I display a entry of the  
NSArray:


NSHTTPCookie version:0 name:@SC value:@RV=661339  
expiresDate:@2038-01-17 11:14:07 -0800 created:@236061243.432815  
sessionOnly:FALSE domain:@.google.com path:@/finance secure:FALSE  
comment:@(null) commentURL:@(null) portList:(null)


Is this a dictionary?  What would be the easiest way to display each  
one of the attributes of the dictionary (version, name, value, etc.)  
in a separate column?  How could I return just one of the attributes?


Thank you!



On Jun 29, 2008, at 12:56 PM, Jens Alfke wrote:



On 29 Jun '08, at 9:39 AM, Chris Purcell wrote:

Thank you for the reply.  I think right now the simplest would be  
to convert the cookies array to an array of NSStrings.  What would  
be the easiest way to do this?


Keep the array as an array of NSHTTPCookies. But your - 
objectValueForTableColumn: should look up the cookie object for the  
row, and then get the right attribute of the cookie based on the  
column identifier. For instance, if the column shows URLs, then you  
should get the URL of the cookie and return its absoluteString. If  
it shows dates, return an NSDate.


—Jens




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]

Ithaca, NY CocoaHeads Now Forming

2008-06-29 Thread Bill Garrison
I'm organizing an Ithaca, NY chapter of CocoaHeads to connect up with  
other developers in the area.


More details at http://standardorbit.net/blog/2008/06/ithaca-cocoaheads-now-forming/ 



- Bill
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: viewing method calls

2008-06-29 Thread Nick Zitzmann


On Jun 29, 2008, at 3:25 PM, John Murphy wrote:

How do I view the messages (method calls) that are sent during the  
loading of an application?



You can do this using a profiler, such as Shark.

Nick Zitzmann
http://www.chronosnet.com/




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: CALayer and View Scaling

2008-06-29 Thread Scott Anguish


On Jun 29, 2008, at 11:25 PM, Gordon Apple wrote:

   BTW, I tried unsuccessfully to observe the clip view's bounds to  
trigger
code to resize the CALayers.  Why can't I observe it?  I finally set  
an

observer on the scale factor in SKTZoomingScrollView.



because the bounds value of views are not KVO compliant.

unless KVO compliance is specifically noted in the reference, don't  
count on it.

___

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

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

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

This email sent to [EMAIL PROTECTED]