IB Plugin - optionDescriptionsForBinding: not called

2009-05-27 Thread Yvan BARTHÉLEMY

Hello,

I have tried to create a custom IB Plugin to support custom bindings/ 
reimplement existing bindings on NSImageView. My final goal is to have  
read/write access to path and url bindings, I intend to reimplement  
drag & drop and create files on the fly to achieve this.


For this I tried to create a simple binding by calling exposeBinding:  
in initialize and implementing valueClassForBinding:. This works, but  
optionDescriptionsForBinding: is not called by IB (tested by adding a  
NSLog on the top of the method). I cannot then add custom checkboxes,  
etc. for the binding.


Should I file a bug about this behavior ? I am using IB 3.1.2 (677).  
Should I switch to an other version of IB ?


Thanks for any help,
Yvan
___

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

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

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

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


Abstract class with single subclass

2009-05-27 Thread Freddie Tilley
If I would want to allocate a class which allocates a single subclass  
instead, to

hide the class implementation details

would this be the correct way of doing it?

The following code would be in the BaseClass

+ (id)allocWithZone:(NSZone*)aZone
{
if ([[self class] isEqualTo:[BaseClass class]])
{
return [[SubClass alloc] init];
} else {
return [super allocWithZone: aZone];
}
}

Freddie Tilley
___

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

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

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

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


NSString initWithFormat and stringWith

2009-05-27 Thread Ignacio Enriquez
Hi.
I have a basic question regarding Class methods and instance methods
and memory allocation. (this is in iPhone OS 3.0 beta 5)

1.- What is the difference between string1 and string2? where
NSString *string1 = [NSString stringWithFormat:@"myFirstString"];
NSString *string2 = [[NSString alloc] initWithFormat:@"mySecondString"];

I thought that string1's memory allocation and release would be done
by the system (autoreleased) and string2's memory and release should
be done by me (by [string2 release])
Am i mistaking?

A funny thing is when doing:
NSLog(@"retainCount %i %i", [string1 retainCoung], [string2 retainCount]);
I got :
"retainCount  2147483647 2147483647"

So It seems that both objects are autorelease objects... Why is that?
 I thougth that string2 retainCount would be 1.

2.- How can I get two simple NSString instances with a retainCount equal to 1

Any response would be very appreciated.
Regards

Ignacio


_
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Jesper Storm Bache

On May 27, 2009, at 6:59 AM, Ignacio Enriquez wrote:

Hi.
I have a basic question regarding Class methods and instance methods
and memory allocation. (this is in iPhone OS 3.0 beta 5)

1.- What is the difference between string1 and string2? where
NSString *string1 = [NSString stringWithFormat:@"myFirstString"];
NSString *string2 = [[NSString alloc]  
initWithFormat:@"mySecondString"];


I thought that string1's memory allocation and release would be done
by the system (autoreleased) and string2's memory and release should
be done by me (by [string2 release])
Am i mistaking?


You are correct.



A funny thing is when doing:
NSLog(@"retainCount %i %i", [string1 retainCoung], [string2  
retainCount]);

I got :
"retainCount  2147483647 2147483647"

So It seems that both objects are autorelease objects... Why is that?
I thougth that string2 retainCount would be 1.


This kind of refcount indicates a "real const" string. You are likely  
to see a different ref-count if you create a mutable string.





2.- How can I get two simple NSString instances with a retainCount  
equal to 1


In general don't worry about the exact ref-count values, but rather on  
making sure that you follow the Cocoa memory rules.
The Leaks tool can assist in finding areas where you forgot to release  
objects. And the zombie mechanism can be used to track down over  
releases.

(since you are on the iPhone garbage collection is not an option).


Jesper Storm Bache
Core Technologies
Adobe Systems Inc




Any response would be very appreciated.
Regards

Ignacio


_
___

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

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

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

This email sent to jsba...@adobe.com


___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Graham Cox


On 27/05/2009, at 11:59 PM, Ignacio Enriquez wrote:


I have a basic question regarding Class methods and instance methods
and memory allocation. (this is in iPhone OS 3.0 beta 5)

1.- What is the difference between string1 and string2? where
NSString *string1 = [NSString stringWithFormat:@"myFirstString"];
NSString *string2 = [[NSString alloc]  
initWithFormat:@"mySecondString"];


I thought that string1's memory allocation and release would be done
by the system (autoreleased) and string2's memory and release should
be done by me (by [string2 release])
Am i mistaking?



No, you are correct.


A funny thing is when doing:
NSLog(@"retainCount %i %i", [string1 retainCoung], [string2  
retainCount]);

I got :
"retainCount  2147483647 2147483647"

So It seems that both objects are autorelease objects... Why is that?
I thougth that string2 retainCount would be 1.

2.- How can I get two simple NSString instances with a retainCount  
equal to 1


Forget retain counts. They are unintuitive and highly misleading. You  
can never know what a retain count can be expected to be. Just follow  
the rules and all will be well.


--Graham


___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Dave DeLong

Hi Ignacio,

I just ran a simple test, pasted below:

NSString * one = [NSString stringWithString:@"Hello"];
NSString * two = [[NSString alloc] initWithString:@"Hello"];
NSLog(@"%X, %X, %X", one, two, @"Hello");

What you see logged is that the three strings point to the same  
address in memory.  From this we can conclude that the compiler is  
optimizing this code, like so: It sees that you're creating a non- 
mutable object from a non-mutable object, and so it replaces them all  
with THE SAME OBJECT.  In this particular case, it's an instance of  
NSConstantString (a private subclass of NSString).  ConstantStrings  
are singletons by default (hence "constant"), and so their retain  
count is hard-coded to something like NSUIntegerMax so that they  
cannot technically be released.  This, however, does not excuse you  
from following the rules of proper memory management.


As others have said, retainCounts are generally non-useful pieces of  
information.


HTH,

Dave

On May 27, 2009, at 7:59 AM, Ignacio Enriquez wrote:


Hi.
I have a basic question regarding Class methods and instance methods
and memory allocation. (this is in iPhone OS 3.0 beta 5)

1.- What is the difference between string1 and string2? where
NSString *string1 = [NSString stringWithFormat:@"myFirstString"];
NSString *string2 = [[NSString alloc]  
initWithFormat:@"mySecondString"];


I thought that string1's memory allocation and release would be done
by the system (autoreleased) and string2's memory and release should
be done by me (by [string2 release])
Am i mistaking?

A funny thing is when doing:
NSLog(@"retainCount %i %i", [string1 retainCoung], [string2  
retainCount]);

I got :
"retainCount  2147483647 2147483647"

So It seems that both objects are autorelease objects... Why is that?
I thougth that string2 retainCount would be 1.

2.- How can I get two simple NSString instances with a retainCount  
equal to 1


Any response would be very appreciated.
Regards

Ignacio


_
___

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

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

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

This email sent to davedel...@me.com


___

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

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

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

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


Re: Abstract class with single subclass

2009-05-27 Thread Michael Ash
On Wed, May 27, 2009 at 9:48 AM, Freddie Tilley  wrote:
> If I would want to allocate a class which allocates a single subclass
> instead, to
> hide the class implementation details
>
> would this be the correct way of doing it?
>
> The following code would be in the BaseClass
>
> + (id)allocWithZone:(NSZone*)aZone
> {
>        if ([[self class] isEqualTo:[BaseClass class]])
>        {
>                return [[SubClass alloc] init];

Close. You only want to do return [SubClass alloc] here. The caller
will be calling -init as usual after your method returns.

Alternatively, you can have a factory method which does both alloc and
init and returns that to the caller. Both work fine, it's pretty much
just a question of what you prefer. Overriding +allocWithZone: works
better if you have many different initializers for the caller to
choose from.

Mike
___

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

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

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

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


Re: Abstract class with single subclass

2009-05-27 Thread Michael Ash
On Wed, May 27, 2009 at 9:48 AM, Freddie Tilley  wrote:
> If I would want to allocate a class which allocates a single subclass
> instead, to
> hide the class implementation details
>
> would this be the correct way of doing it?
>
> The following code would be in the BaseClass
>
> + (id)allocWithZone:(NSZone*)aZone
> {
>        if ([[self class] isEqualTo:[BaseClass class]])

Oops, I forgot to mention one other thing. This works but is
excessively wordy and strange. In a class method, [self class] is
equivalent to self. -isEqualTo: is a method that exists for
AppleScript support; the proper one to use is -isEqual:. However,
since class equality is always the same as object identity, you don't
need to use a method at all, but can shorten it down to if(self ==
[BaseClass class]).

Mike
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Erik Buck

Don't ever write either of the following lines:
> NSString *string1 = [NSString stringWithFormat:@"myFirstString"];
> NSString *string2 = [[NSString alloc]  
initWithFormat:@"mySecondString"];


the WithFormat methods parse the argument string.  If your argument  
string contains any '%' characters those lines will likely crash.


Use NSString *string1 = [NSString stringWithString:@"myFirstString"];
or NSString *string2 = [[[NSString alloc]  
initWithString:@"mySecondString"] autorelease];


As I have written it above, you are not taking responsibility for  
later releasing either string1 or string2.


As an alternative, use
NSString *string1 = [[NSString stringWithString:@"myFirstString"]  
retain];
or NSString *string2 = [[NSString alloc]  
initWithString:@"mySecondString"];

or NSString *string3 = [@"myThirdString" copy];

In all of the alternate cases, you are taking responsibility for later  
releasing string1, string2, and string3.


As requested by the moderators for good reason and rather than  
misstate the simple memory management rules, I will just reference the  
official answer which is clear and precise and easy to follow: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html


___

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

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

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

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


Re: Abstract class with single subclass

2009-05-27 Thread Freddie Tilley


On 27 mei 2009, at 16:51, Michael Ash wrote:

On Wed, May 27, 2009 at 9:48 AM, Freddie Tilley   
wrote:

If I would want to allocate a class which allocates a single subclass
instead, to
hide the class implementation details

would this be the correct way of doing it?

The following code would be in the BaseClass

+ (id)allocWithZone:(NSZone*)aZone
{
  if ([[self class] isEqualTo:[BaseClass class]])


Oops, I forgot to mention one other thing. This works but is
excessively wordy and strange. In a class method, [self class] is
equivalent to self. -isEqualTo: is a method that exists for
AppleScript support; the proper one to use is -isEqual:. However,
since class equality is always the same as object identity, you don't
need to use a method at all, but can shorten it down to if(self ==
[BaseClass class]).


Thanks for your help!

Freddie Tilley
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Sherm Pendley
On Wed, May 27, 2009 at 9:59 AM, Ignacio Enriquez  wrote:

>
> 1.- What is the difference between string1 and string2? where
> NSString *string1 = [NSString stringWithFormat:@"myFirstString"];
> NSString *string2 = [[NSString alloc] initWithFormat:@"mySecondString"];


You own string2 and must release it when you're done with it.

You do not own string1 and must not release it.


> I thought that string1's memory allocation and release would be done
> by the system (autoreleased) and string2's memory and release should
> be done by me (by [string2 release])
> Am i mistaking?


Yes, you are mistaken. :-(

The memory contract concerns ownership - i.e. what are the calling code's
responsibilities with respect to retain and/or release. Many objects that
you do not own are in fact autoreleased, but there is no guarantee of that.
The only guarantee concerns whether the caller owns the returned object.
That contract works both ways; the called code is also required to return an
object that behaves correctly if the caller fulfills its end of the
contract. *How* the called method does so is an implementation detail that's
not part of the contract, and something the caller need not care about.

A funny thing is when doing:
> NSLog(@"retainCount %i %i", [string1 retainCoung], [string2 retainCount]);
> I got :
> "retainCount  2147483647 2147483647"
>
> So It seems that both objects are autorelease objects... Why is that?
>  I thougth that string2 retainCount would be 1.


With no placeholders in your format, NSString is perfectly within its rights
to return a singleton instance that represents the constant static string
that's compiled into your binary. For such singletons, the retain count is
often set to a "special" value that the -release method will recognize as
meaning "can't touch this." So no, these objects are not autoreleased.

But, it doesn't matter. All that your code needs to do is follow the
contract, and release string2 when it's done with it.

2.- How can I get two simple NSString instances with a retainCount equal to
> 1


You can't depend on any particular value of retainCount. You shouldn't even
be looking at it - as you've seen, it's an internal implementation detail
that can (and does) have values that are only meaningful if you're
maintaining the target class - in this case, NSString.

Take a step further back - what problem are you having, that led you to
think that looking at retainCount would help you solve it?

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 arch...@mail-archive.com


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Ignacio Enriquez
First:

I just realized that one of my statements was incorrect;

NSString *string2 = [[NSString alloc] initWithFormat:@"mySecondString"];

does not make string2 retainCount to be 2147483647, it only becomes
2147483647 when   inserting @"" instead of @"mySecondString"

And regarding why use retainCount?
Well I am trying to find where is my mistake, since sometimes my
application crashes and I am quite (99.9%) sure that I am releasing a
object that shouldn't be.

Any ideas how to find such a bug?
Thanks in advance.
Regards

Ignacio.


On Thu, May 28, 2009 at 12:14 AM, Sherm Pendley  wrote:
> On Wed, May 27, 2009 at 9:59 AM, Ignacio Enriquez  wrote:
>>
>> 1.- What is the difference between string1 and string2? where
>> NSString *string1 = [NSString stringWithFormat:@"myFirstString"];
>> NSString *string2 = [[NSString alloc] initWithFormat:@"mySecondString"];
>
> You own string2 and must release it when you're done with it.
>
> You do not own string1 and must not release it.
>
>>
>> I thought that string1's memory allocation and release would be done
>> by the system (autoreleased) and string2's memory and release should
>> be done by me (by [string2 release])
>> Am i mistaking?
>
> Yes, you are mistaken. :-(
>
> The memory contract concerns ownership - i.e. what are the calling code's
> responsibilities with respect to retain and/or release. Many objects that
> you do not own are in fact autoreleased, but there is no guarantee of that.
> The only guarantee concerns whether the caller owns the returned object.
> That contract works both ways; the called code is also required to return an
> object that behaves correctly if the caller fulfills its end of the
> contract. *How* the called method does so is an implementation detail that's
> not part of the contract, and something the caller need not care about.
>
>> A funny thing is when doing:
>> NSLog(@"retainCount %i %i", [string1 retainCoung], [string2 retainCount]);
>> I got :
>> "retainCount  2147483647 2147483647"
>>
>> So It seems that both objects are autorelease objects... Why is that?
>>  I thougth that string2 retainCount would be 1.
>
> With no placeholders in your format, NSString is perfectly within its rights
> to return a singleton instance that represents the constant static string
> that's compiled into your binary. For such singletons, the retain count is
> often set to a "special" value that the -release method will recognize as
> meaning "can't touch this." So no, these objects are not autoreleased.
>
> But, it doesn't matter. All that your code needs to do is follow the
> contract, and release string2 when it's done with it.
>
>> 2.- How can I get two simple NSString instances with a retainCount equal
>> to 1
>
> You can't depend on any particular value of retainCount. You shouldn't even
> be looking at it - as you've seen, it's an internal implementation detail
> that can (and does) have values that are only meaningful if you're
> maintaining the target class - in this case, NSString.
>
> Take a step further back - what problem are you having, that led you to
> think that looking at retainCount would help you solve it?
>
> 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 arch...@mail-archive.com


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Bill Bumgarner

On May 27, 2009, at 8:34 AM, Ignacio Enriquez wrote:

And regarding why use retainCount?
Well I am trying to find where is my mistake, since sometimes my
application crashes and I am quite (99.9%) sure that I am releasing a
object that shouldn't be.


Using -retainCount won't help you;   a tempting, but ultimately,  
futile path to follow.


Use NSZombies or Instrument's ObjectAlloc instrument.

b.bum

___

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

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

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

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


UITableView data source/delegate flow of control

2009-05-27 Thread WT

Hello...

So, in order to better understand the flow of control when accessing a  
UITableView instance, I created a tiny project with a single section,  
having a single row, and then implemented every one of the 29 data  
source and delegate methods to do trivial things in addition to  
printing a log message to the console window. The result surprised me  
in that two methods that I would think would be called only once per  
section each are each being called twice per section. Take a look at  
the log messages below (for the boring case of starting the app and  
then immediately closing it, without any other interaction) and note  
that


-tableView: heightForHeaderInSection: and -tableView:  
heightForFooterInSection:


are both being called twice in sequence for the single section. Note  
also that the same does not happen to the method


-tableView: heightForRowAtIndexPath:

which is called only once per row per section, as expected.

Now, of course, it's probably the case that there is some private code  
being executed between those two calls to the same method, but I would  
have expected the result of the first call to be cached, obviating the  
second call.


It's also interesting that

-tableView: viewForHeaderInSection: and -tableView:  
titleForHeaderInSection:


(and the corresponding methods for the footer) are also being called  
twice in the process of drawing the row cell.


[Session started at 2009-05-27 17:20:38 +0200.]
2009-05-27 16:46:41.065 TableViewExample[45503:20b]
2009-05-27 16:46:41.067 TableViewExample[45503:20b] - 
numberOfSectionsInTableView:

2009-05-27 16:46:41.068 TableViewExample[45503:20b]
2009-05-27 16:46:41.068 TableViewExample[45503:20b] -tableView:  
viewForHeaderInSection:
2009-05-27 16:46:41.069 TableViewExample[45503:20b] -tableView:  
titleForHeaderInSection:
2009-05-27 16:46:41.069 TableViewExample[45503:20b] -tableView:  
heightForHeaderInSection:
2009-05-27 16:46:41.069 TableViewExample[45503:20b] -tableView:  
heightForHeaderInSection:

2009-05-27 16:46:41.070 TableViewExample[45503:20b]
2009-05-27 16:46:41.070 TableViewExample[45503:20b] -tableView:  
viewForFooterInSection:
2009-05-27 16:46:41.071 TableViewExample[45503:20b] -tableView:  
titleForFooterInSection:
2009-05-27 16:46:41.071 TableViewExample[45503:20b] -tableView:  
heightForFooterInSection:
2009-05-27 16:46:41.072 TableViewExample[45503:20b] -tableView:  
heightForFooterInSection:

2009-05-27 16:46:41.072 TableViewExample[45503:20b]
2009-05-27 16:46:41.073 TableViewExample[45503:20b] -tableView:  
numberOfRowsInSection:
2009-05-27 16:46:41.073 TableViewExample[45503:20b] -tableView:  
heightForRowAtIndexPath:

2009-05-27 16:46:41.074 TableViewExample[45503:20b]
2009-05-27 16:46:41.074 TableViewExample[45503:20b] - 
sectionIndexTitlesForTableView:

2009-05-27 16:46:41.082 TableViewExample[45503:20b]
2009-05-27 16:46:41.083 TableViewExample[45503:20b] -tableView:  
cellForRowAtIndexPath:
2009-05-27 16:46:41.084 TableViewExample[45503:20b] -tableView:  
indentationLevelForRowAtIndexPath:
2009-05-27 16:46:41.084 TableViewExample[45503:20b] -tableView:  
canEditRowAtIndexPath:
2009-05-27 16:46:41.085 TableViewExample[45503:20b] -tableView:  
willDisplayCell: forRowAtIndexPath:

2009-05-27 16:46:41.085 TableViewExample[45503:20b]
2009-05-27 16:46:41.086 TableViewExample[45503:20b] -tableView:  
viewForHeaderInSection:
2009-05-27 16:46:41.086 TableViewExample[45503:20b] -tableView:  
titleForHeaderInSection:
2009-05-27 16:46:41.086 TableViewExample[45503:20b] -tableView:  
heightForHeaderInSection:

2009-05-27 16:46:41.087 TableViewExample[45503:20b]
2009-05-27 16:46:41.087 TableViewExample[45503:20b] -tableView:  
viewForFooterInSection:
2009-05-27 16:46:41.087 TableViewExample[45503:20b] -tableView:  
titleForFooterInSection:
2009-05-27 16:46:41.088 TableViewExample[45503:20b] -tableView:  
heightForFooterInSection:

2009-05-27 16:46:41.089 TableViewExample[45503:20b]
2009-05-27 16:46:41.090 TableViewExample[45503:20b] -tableView:  
viewForHeaderInSection:
2009-05-27 16:46:41.090 TableViewExample[45503:20b] -tableView:  
titleForHeaderInSection:

2009-05-27 16:46:41.094 TableViewExample[45503:20b]
2009-05-27 16:46:41.094 TableViewExample[45503:20b] -tableView:  
viewForFooterInSection:
2009-05-27 16:46:41.095 TableViewExample[45503:20b] -tableView:  
titleForFooterInSection:

Terminating in response to SpringBoard's termination.

The results above are for the case when

-tableView: viewForHeaderInSection: and -tableView:  
viewForFooterInSection:


both return nil. It turns out that if the view that's returned isn't  
nil, the title and height calls are still made exactly as in the nil  
case, but the view frame is completely ignored. Instead, the view is  
laid out left-adjusted, with the full width of the screen, but with  
the height returned by the call to the height method. See the log  
messages below for the case when both header and footer views are non- 
nil.


[Session started at 2009-

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Michael Ash
On Wed, May 27, 2009 at 11:05 AM, Erik Buck  wrote:
> As an alternative, use
> NSString *string1 = [[NSString stringWithString:@"myFirstString"] retain];
> or NSString *string2 = [[NSString alloc] initWithString:@"mySecondString"];
> or NSString *string3 = [@"myThirdString" copy];

However you should never use any of these either.

You already have a string. If you need a string, then you have it, so use it.

This code can be *occasionally* useful if you need an independent copy
of a potentially mutable string. But of course @"" constructs are
never mutable.

This may seem nitpicky but I see a lot of newbies writing code just
like this. Their code is filled with stringWithString: calls for
absolutely no purpose, so I want to discourage that sort of thing.

Mike
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Ignacio Enriquez
Thanks to all!

NSZombiesEnabled YES
Is really helpfull, now I now where to start!;)

I wish I would have known this before.
Cheers


On Thu, May 28, 2009 at 12:38 AM, Bill Bumgarner  wrote:
> On May 27, 2009, at 8:34 AM, Ignacio Enriquez wrote:
>>
>> And regarding why use retainCount?
>> Well I am trying to find where is my mistake, since sometimes my
>> application crashes and I am quite (99.9%) sure that I am releasing a
>> object that shouldn't be.
>
> Using -retainCount won't help you;   a tempting, but ultimately, futile path
> to follow.
>
> Use NSZombies or Instrument's ObjectAlloc instrument.
>
> b.bum
>
>



-- 

慶應義塾大学大学院 理工学研究科
開放環境科学専攻 斎藤英雄研究室
修士1年 Guillermo Ignacio Enriquez G.
e-mail :  nach...@hvrl.ics.keio.ac.jp

_
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Alex Curylo


On 27-May-09, at 8:41 AM, cocoa-dev-requ...@lists.apple.com wrote:


Well I am trying to find where is my mistake, since sometimes my
application crashes and I am quite (99.9%) sure that I am releasing a
object that shouldn't be.

Any ideas how to find such a bug?


As long as the crashes happen when you're running under the debugger,  
if you set in Xcode the five global breakpoints I list here


http://www.alexcurylo.com/blog/2008/11/13/tip-debugging-exceptions/

you'll catch every fatal occurrence (every likely fatal occurrence,  
anyways...) at the moment it occurs. Deducing the probable cause is  
then *much* less challenging. Downright trivial, generally.


--
Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/

Programming is like sex...
One mistake and you support it the rest of your life.





___

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

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

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

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


NSURLConnection sendSynchronousRequest and NSString stringWithContentsOfURL crashing under 10.5.7

2009-05-27 Thread Dennis Hartigan-O'Connor
I have a little app that downloads stock prices and was working 
perfectly (for years) until my recent upgrade to 10.5.7. After the 
upgrade, the program would crash on this call:


NSString *currinfo = [NSString stringWithContentsOfURL:[NSURL 
URLWithString:[NSString 
stringWithFormat:@"http://finance.yahoo.com/d/quotes.csv?s=%@&f=l1c1p2";, 
escsymbol]]];


Oddly, the crash doesn't happen right away. This line of code is called 
many times, with no problems, and then the program eventually fails 
after 1-2 hours due to a crash on this call.


Seeing that stringWithContentsOfURL is deprecated, I switched to this code:

pathURL = [NSURL URLWithString:[NSString 
stringWithFormat:@"http://finance.yahoo.com/d/quotes.csv?s=%@&f=l1c1p2";, 
escsymbol]];


NSURLRequest *request = [NSURLRequest requestWithURL:pathURL 
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0];


responseData = [ NSURLConnection sendSynchronousRequest:request 
returningResponse:&response error:&error];


NSString *currinfo = nil;

if ([error code]) {  dNSLog((@"%@ %d %@ %@ %@", [ error domain], [ error 
code], [ error localizedDescription], request, 
@"file://localhost/etc/gettytab"));  }


This didn't help. The program still crashes on the 
sendSynchronousRequest line after an arbitrary length of time, with this 
information in the debugger:


0   0x93db7286 in mach_msg_trap
1   0x93dbea7c in mach_msg
2   0x946ba04e in CFRunLoopRunSpecific
3   0x946bac78 in CFRunLoopRunInMode
4   0x932b53eb in CFURLConnectionSendSynchronousRequest
5   0x905dca4b in +[NSURLConnection 
sendSynchronousRequest:returningResponse:error:]


...etc.

The real crash might actually be in a different thread:

0   libobjc.A.dylib 0x965c3688 objc_msgSend + 24
1   com.apple.CoreFoundation0x946cc581 _CFStreamSignalEventSynch 
+ 193

2   com.apple.CoreFoundation0x946ba595 CFRunLoopRunSpecific + 3141
3   com.apple.CoreFoundation0x946bac78 CFRunLoopRunInMode + 88
4   com.apple.Foundation0x9058c530 
+[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 320

5   com.apple.Foundation0x90528e0d -[NSThread main] + 45
6   com.apple.Foundation0x905289b4 __NSThread__main__ + 308
7   libSystem.B.dylib   0x93de8155 _pthread_start + 321
8   libSystem.B.dylib   0x93de8012 thread_start + 34

which I presume is the thread spawned to download the URL. By the way, 
the error handling code works fine--when I intentionally cause an error 
by disconnecting from the internet, the error is just reported in the 
console and the program doesn't crash.


This is incredibly frustrating. I would be very happy to spend as much 
time as necessary tracking down the problem, but I'm kind of at the 
limits of my knowledge with gdb and especially with assembly language. I 
don't know how to find out what is the actual problem for the Foundation 
code. At first I thought that maybe the autoreleased NSString escsymbol 
is somehow being deallocated, but sending it a retain message didn't 
help. If this were the case, how could I prove it?


Is anybody else having this problem?
___

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

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

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

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


Field Editor Size in NSTableView

2009-05-27 Thread Timothy Larkin
I have an NSTableView that has rows of variable height, depending on  
the amount of text in a specific column. This works.


If I resize the column, the row height adjusts correctly as the text  
is rewrapped.


If I edit the contents of a cell, the field editor appears having the  
expected size. It has the height of the row and consequently shows all  
the text.


If I resize the column while the field editor is active, the field  
editor resizes to fit the column width and row height, which varies as  
the text is rewrapped to fit the new column width.


This is all well and good.

However, if I change the edited text sufficiently that the number of  
lines changes, the row height changes correctly, but the size of the  
field editor does not change. For instance, if the text requires two  
lines, and I delete one line, the row height changes, but the field  
editor is still the height of two lines. If I add a line, the row  
height changes to 3 lines, but the field editor is still 2 lines.


Under these circumstances, the numerical dimensions of the frame of  
the field editor change, but the size of the focus ring does not  
change, and rectangle of text that is visible does not change. So  
changing the field editor's frame does not help.


Resizing the column makes everything good again. So there must be some  
property of the field editor that can be modified so that it follows  
the row height. Presumably this could be changed without resizing the  
column. But hours of search and experimentation have been in vain.



--
Timothy Larkin
Abstract Tools
Caroline, NY

___

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

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

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

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


NSTextFieldCell Delegate?

2009-05-27 Thread Walker Argendeli
I have a text field cell in a table view, from which I need to be made  
aware when it ends editing.  I thought I would set my Controller class  
as the text field cell's delegate, and then use NSTextField's delegate  
method textDidEndEditing:, but realized that the text field cell  
doesn't seem to have delegate methods?  Why is this, and what can I do  
(other than subclassing) to be informed when editing is finished?


- Walker Argendeli

___

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

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

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

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


NSTextFieldCell Delegate?

2009-05-27 Thread Greg Guerin

Walker Argendeli wrote:

I have a text field cell in a table view, from which I need to be  
made aware when it ends editing. I thought I would set my  
Controller class as the text field cell's delegate, and then use  
NSTextField's delegate method textDidEndEditing:, but realized that  
the text field cell doesn't seem to have delegate methods? Why is  
this, and what can I do (other than subclassing) to be informed  
when editing is finished?



Google keywords, taken directly from your Subject line:
  NSTextFieldCell Delegate

  -- GG

___

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

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

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

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


Re: Bound NSPopUpButton + null at the beginning

2009-05-27 Thread Stamenkovic Florijan


On May 26, 2009, at 16:55, Stamenkovic Florijan wrote:


Hi all,


I am trying to figure out how to properly accomplish the following,  
and after reading docs, references and googling, I am still stuck.  
Any help appreciated:


1. Have an NSPopUp, "Contents" and "Content values" bound to an  
NSArrayController's "arrangedObjects" and "arrangedObjects.name",  
respectively.
2. Have the window title bound to the NSArrayController  
"selection.name", and have a replacement string in case of no(null)  
selection, or empty selection

3. Have a selectable null at the beginning of the popup.

I have two possible solutions, but both are flawed.

1. Bind the NSPopUp's selected index to NSArrayController's selected  
index. Use "Inserts Null Placeholder" in the Contents binding to  
make sure I get a selectable null at the beginning of the popup. The  
problem is that if I at some point choose the null in the popup, the  
window title does not get updated with the replacement string, and I  
get a log statement:


[ setNilValueForKey]: could not set nil  
as the value for the key selectionIndex.


2. To work around this, I tried adding an [NSNull null] at the  
beginning of the NSArrayController's contents array. And deselect  
the "Inserts Null Placeholder" in popup's contents binding. This  
solves the selectionIndex issue, but it introduces a different  
problem. Now if I select the null in the popup, my window title does  
not get updated with the replacement string, but with the ""  
text. It seems that [NSNull null] is not seen as something to be  
replaced with the Null replacement string. I also get a log statement:


Cannot create NSArray from object  of class NSNull


Is there an elegant way of dealing with this? I am thinking that  
somehow it should be possible to bind the popup selected value  
directly to the controller's selection. Then I could use the  
approach described under (1), but avoid the index issue. However, I  
can't seem to do that. The "Selected object" binding of the popup  
seems to be incompatible with the NSArrayController "selection", as  
the NSArrayController seems to wrap the selection in a proxy. The  
NSArrayController's "selectedObjects" deals with NSArrays, not  
individual values. Perhaps if I used a custom value converter that  
converts from NSArray* to it's object at 0 index? Or is there a  
better solution?


The value converter approach seems to work OK, in case anyone is  
interested. I'd still be happy to learn a more concise way to do this,  
if there is one.


F
___

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

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

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

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


Traversing an NSXML subtree

2009-05-27 Thread McLaughlin, Michael P.
In reviewing the NSXML documents, I found no really simple way to traverse a
subtree of an NSXMLDocument.  That is, traverse from the root until you hit
the node with the right name then pretend that that node is the root of a
smaller tree and traverse just the latter.  [Everything I found talked only
about sibs and (immediate) children, not grandchildren, etc.]

Since this is such a common thing to do, I'm guessing that I must have
misread the docs somehow.

Could someone clue me in as to the preferred method to do a subtraversal?

TIA.

-- 
Mike McLaughlin

___

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

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

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

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


Re: Using fmdb with Cocoa Bindings

2009-05-27 Thread Kelvin Chung


On May 27, 2009, at 11:06 AM, Bill Garrison wrote:



On May 27, 2009, at 1:33 AM, Kelvin Chung wrote:

I'm fairly new to both fmdb and Cocoa bindings, so I am wondering  
if anyone can help me out:


Suppose I have an FMResultSet resulting in a query.  I'm trying to  
put the results in an NSTableView with Cocoa Bindings.  Now the  
table view has its contentArray bound to an NSArrayController (call  
it controller), whose content array is bound to the key "species"  
of a class named "SpeciesView".


So, in SpeciesView I should have -countOfSpecies and - 
objectInSpeciesAtIndex:.  However, I'm now having trouble bridging  
the two ends, and I am wondering if someone experienced can help:  
how can I get from an FMResultSet the implementations of these two  
methods?


With an FMResultSet, you need to process it further to extract the  
juicy Cocoa objects.  A result set will have 0, 1, or n rows of data  
in it, depending on the nature of the SQL query you executed.


Here's a snippet derived from the fmdb.m test example:

   FMResultSet *rs = [db executeQuery:@"select * from test where a  
= ?", @"hi"];

   while ( [rs next] ) {
   // just print out what we've got in a number of formats.
   NSLog(@"%d %@ %@ %@ %f %f",
 [rs intForColumn:@"c"],
 [rs stringForColumn:@"b"],
 [rs stringForColumn:@"a"],
 [rs dateForColumn:@"d"],
 [rs doubleForColumn:@"d"],
 [rs doubleForColumn:@"e"]);
   }


This SQL query asks for all columns in the 'test' table where column  
'a' equals "hi".  The result set can contain 0..n rows, so you use a  
while loop to iterate the result set, accessing the objects out of  
each column as needed.  You'll need a similar while loop to process  
your result set, populating the 'species' array in your model.


Right.  Having done so, I'm puzzled as to where the code to do so  
actually goes:


Suppose I have an application delegate class that creates the  
FMDatabase, and I have a query that populates the table view.  Suppose  
the controller code is in SpeciesView, where I have a query string.   
Right now, I have it -species execute the query to populate the table  
(prolly a bad idea, but I don't know how to do it better).


However, it seems that the -species is executed before the database is  
open (in particular, -applicationDidFinishLaunching: in the  
application delegate, which loads the database).  Thus, the table view  
appears empty.  How can I change this so that the table view is  
initially populated?

___

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

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

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

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


stripping question

2009-05-27 Thread Eric Slosser
I use 'strip -i -s savedSyms.txt my.app/Contents/MacOS/my' to remove  
symbols that aren't necessary.


savedSyms.txt used to only contain typeinfo symbols (start with  
"__ZTI") that are necessary for cross-library exception catching to  
work.


But today, I discovered the need to preserve  
".objc_class_name_CalController", or the stripped app would crash at  
launch with an attempt to read from $0x0. The crash is inside some  
anonymous code, called by  
ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&).


Only the release build crashes, I can strip that symbol from the debug  
build and it doesn't care. The crash is on 10.5.6 or 10.5.7, I haven't  
checked other versions.  I'm building with Xcode 3.1.1.


MyController is referred to by some XIBs, so I thought maybe there's  
something going on at NIB loading time, but removing the XIBs from the  
project and rebuilding/restripping the .app doesn't remove the crash.   
AFAIK, there's no static variable that attempts to construct a  
CalController.


Why is this symbol required to launch?
___

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

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

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

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


Re: Core data, bindings and multiple view NIB

2009-05-27 Thread Keary Suska

On May 27, 2009, at 12:30 AM, Tomaž Kragelj wrote:


GroupItemsController:
- managed object context -> Application.delegate.managedObjectContext
- ???
The question marks are what I'm missing - if I don't bind to  
anything, then the array controller will simply show all items for  
all groups, however I want to bind this to the GroupItemsController  
from the MainMenu.nib (it is accessible through the  
Application.delegate, but I don't know how to bind it in order to  
show only the items selected by the group in GroupsView.nib...


Have you tried Application.delegate.GroupController.selection.items  
(the last key os whatever relationship you need to use)?


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

___

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

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

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

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


Re: Abstract class with single subclass

2009-05-27 Thread Seth Willits

On May 27, 2009, at 7:51 AM, Michael Ash wrote:


   if ([[self class] isEqualTo:[BaseClass class]])


Oops, I forgot to mention one other thing. This works but is
excessively wordy and strange. In a class method, [self class] is
equivalent to self.


Actually, I accidently used [self class] in a class method two weeks  
ago, and it was causing a crash. I forget the circumstances, but when  
I caught that I was using [self class] and changed it to self,  
everything worked fine. So I don't know what the difference is, but  
there apparently is a difference.



--
Seth Willits



___

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

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

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

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


Re: NSTextFieldCell Delegate?

2009-05-27 Thread Shlok Datye
You could set a delegate for the NSTableView itself. In that delegate,  
you would implement the


- (void)controlTextDidEndEditing:(NSNotification *)note

delegate method. Within that method, you should be able to get the  
information you need. For example,


NSTableView *tableView = [note object];
int colIndex = [tableView editedColumn];
int rowIndex = [tableView editedRow];
NSText *fieldEditor = [tableView currentEditor];

would give you column and row indices and the field editor.

Shlok Datye
Coding Turtle
http://codingturtle.com

On 27.05.2009, at 19:46, Walker Argendeli wrote:

I have a text field cell in a table view, from which I need to be  
made aware when it ends editing.  I thought I would set my  
Controller class as the text field cell's delegate, and then use  
NSTextField's delegate method textDidEndEditing:, but realized that  
the text field cell doesn't seem to have delegate methods?  Why is  
this, and what can I do (other than subclassing) to be informed when  
editing is finished?


- Walker Argendeli

___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-27 Thread Keith Duncan
Could someone clue me in as to the preferred method to do a  
subtraversal?


Have you looked at XPath, it will save you from having to enumerate  
and perform element-name string comparisons.


Keith
___

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

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

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

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


Re: Abstract class with single subclass

2009-05-27 Thread Dave Keck
> Actually, I accidently used [self class] in a class method two weeks ago,
> and it was causing a crash. I forget the circumstances, but when I caught
> that I was using [self class] and changed it to self, everything worked
> fine. So I don't know what the difference is, but there apparently is a
> difference.

That sure sounds strange. +class is plainly defined as a class method
of NSObject. If it's crashing, it sure seems like that'd be a pretty
significant (and probably well-known) bug. The first things that come
to mind that might result in +class crashing are either doing
something fancy with distributed/proxy objects, or perhaps the bundle
that defined the class was unloaded before +class got called.

In "normal" everyday use, [self class] in a class method should never
cause problems, AFAIK.

David
___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-27 Thread Greg Guerin

McLaughlin, Michael P.:

In reviewing the NSXML documents, I found no really simple way to  
traverse a
subtree of an NSXMLDocument.  That is, traverse from the root until  
you hit
the node with the right name then pretend that that node is the  
root of a
smaller tree and traverse just the latter.  [Everything I found  
talked only

about sibs and (immediate) children, not grandchildren, etc.]

Since this is such a common thing to do, I'm guessing that I must have
misread the docs somehow.

Could someone clue me in as to the preferred method to do a  
subtraversal?


Recursion:
 http://en.wikipedia.org/wiki/Recursion

Given any NSXMLNode, if it has children, you can traverse the  
children.  Since each child is itself an NSXMLNode, the "Given any  
NSXMLNode..." sentence at the begining of this paragraph applies.   
The previous two sentences are recursive.


Start recursion at the root node of the NSXMLDocument.

  -- GG



___

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

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

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

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


Bindings and core data

2009-05-27 Thread Michael Süssner

Hi
I am experimenting with core data and bindings.

I have a core data table with a one to-many relationship named  
"participants"


I have in the same view another table displaying a list of  
participants. I want to add additional participants using a Popuplist  
with contacts and a participant is related to contacts.


So, when I have selected a contact entry, I press a button which calls  
method of the PopUpMenu Controller Object, which reads the selected  
Object by


vContact = [[self selectedObjects] objectAtIndex:0];


I have defined in the PopupMenu Controller Object
IBOutlet NSMutableSet *selParticipants;

which I have bound to the table.selection.participants

(I do not understand that IB complains that it is not NSMutableSet)


Then I want to add the vContact to the selection.participants using  
addObjects but the table of participants displays invalid values.


I am not sure what is the mistake.

Michael
___

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

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

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

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


Re: Abstract class with single subclass

2009-05-27 Thread Seth Willits


On May 27, 2009, at 2:15 PM, Dave Keck wrote:

Actually, I accidently used [self class] in a class method two  
weeks ago,
and it was causing a crash. I forget the circumstances, but when I  
caught
that I was using [self class] and changed it to self, everything  
worked
fine. So I don't know what the difference is, but there apparently  
is a

difference.


That sure sounds strange. +class is plainly defined as a class method
of NSObject. If it's crashing, it sure seems like that'd be a pretty
significant (and probably well-known) bug. The first things that come
to mind that might result in +class crashing are either doing
something fancy with distributed/proxy objects, or perhaps the bundle
that defined the class was unloaded before +class got called.

In "normal" everyday use, [self class] in a class method should never
cause problems, AFAIK.


To clarify, it wasn't calling [self class] that caused the problem,  
but rather it crashed later on when using the returned instance. I'm  
pretty sure it was during the initial app launch. It'd take quite a  
bit of investigation to find it, but it was some wacky crash, the  
signature of which I had never seen before.


I know this isn't exactly a very detailed description, but if they  
were equivalent, then changing [self class] to self shouldn't have  
fixed it, but it did. Pretty weird.


*shrug*

--
Seth Willits



___

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

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

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

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


workaround: stubborn text attributes in NSTextView

2009-05-27 Thread Andy Lee
I had a problem with NSTextView refusing to use the text attributes I assigned 
to it.  Here's my workaround in case anyone else runs into the same problem.

I configured an NSTextView in IB with a custom text color, a bit of dummy text 
with a custom font, and rich text turned off (i.e., it's plain text).  The 
problem was that when the user deletes all the text, the text view reverts to 
black Helvetica 12.

I googled "empty NSTextView site:cocoabuilder.com" and found some people had 
solved similar problems by writing a delegate method that futzes with the text 
view's typingAttributes.  I was about to try that but noticed my text view's 
typingAttributes was nil.  (The difference may be that the other people who had 
problems were using rich-text text views.)

After a bunch of trial and error I got it to work by temporarily changing the 
rich-text flag to YES and selecting some non-empty text:

[myTextView setRichText:YES];
[myTextView selectAll:nil];  // make sure text is non-empty
//NSLog(@"typing attributes: %@", [myTextView 
typingAttributes]);
[myTextView setRichText:NO];

It seems this forces the text view to set its typingAttributes, which it then 
dutifully applies in all subsequent editing.

I'll file a Radar when I get home, but I'm posting here now in case someone can 
tell me it's a known issue and/or I'm Doing It Wrong.  I have a vague feeling 
I'm missing something obvious.

Well, I'm also posting so I can paste a URL to this thread in my code comments. 
:)

--Andy


___

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

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

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

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


Re: workaround: stubborn text attributes in NSTextView

2009-05-27 Thread Kyle Sluder
On Wed, May 27, 2009 at 2:58 PM, Andy Lee  wrote:
> I configured an NSTextView in IB with a custom text color, a bit of dummy 
> text with a custom font, and rich text turned off (i.e., it's plain text).  
> The problem was that when the user deletes all the text, the text view 
> reverts to black Helvetica 12.

Just did this yesterday.  Sign yourself up as the text storage's
delegate (or listen for its
NSTextStorageWillProcessEditingNotification) and implement
-textStorageWillProcessEditing: to force your desired attributes.

--Kyle Sluder
___

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

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

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

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


Re: Traversing an NSXML subtree

2009-05-27 Thread Kyle Sluder
On Wed, May 27, 2009 at 2:16 PM, Greg Guerin  wrote:
> Recursion:

Be careful if you're processing arbitrary XML documents; you only have
8MB of stack to work with by default, and each stack frame adds up
quickly.  You might need to turn your recursive solution into an
iterative one.

--Kyle Sluder
___

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

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

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

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


Re: stripping question

2009-05-27 Thread Kyle Sluder
On Wed, May 27, 2009 at 1:35 PM, Eric Slosser  wrote:
> Why is this symbol required to launch?

Does MyController have an +initialize method, or does any other
class's +initialize method possibly create an instance of or call a
class method of MyController?

--Kyle Sluder
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Andy Lee
On Wednesday, May 27, 2009, at 11:48AM, "Michael Ash"  
wrote:
>This may seem nitpicky but I see a lot of newbies writing code just
>like this. Their code is filled with stringWithString: calls for
>absolutely no purpose, so I want to discourage that sort of thing.

Just for grins, I searched for calls to stringWithString: in the Apple examples 
and came across a puzzling comment in 
/Developer/Examples/CoreAudio/AudioUnits/SampleAUs/CocoaUI/SampleEffectCocoaViewFactory.m:


- (NSString *) description {
// don't return a hard coded string (e.g.: @"Sample Effect Cocoa UI") 
because that string may be destroyed (NOT released)
// when this factory class is released.
return [NSString stringWithString:@"Sample Effect Cocoa View"];
}


It looks like an Audio Unit is some kind of pluggable module?  So maybe if an 
NSString constant had been used it would get unloaded when the module is 
unloaded -- hence the stringWithString:?

I noticed the doc for stringWithString: says that it copies the string's 
characters, so in theory it's guaranteed to create a new instance, unlike copy 
which will return the self-same instance when the receiver is immutable.  On 
the other hand, the doc for copyWithZone: says it returns a new instance, which 
it doesn't necessarily.  I'll file a documentation Radar about this later -- 
the vast majority of the time it's an implementation detail we shouldn't care 
about, but there are times it's useful to know when a copy is not a copy.

--Andy



___

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

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

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

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


Re: workaround: stubborn text attributes in NSTextView

2009-05-27 Thread Andy Lee
On Wednesday, May 27, 2009, at 06:34PM, "Kyle Sluder"  
wrote:
>On Wed, May 27, 2009 at 2:58 PM, Andy Lee  wrote:
>> I configured an NSTextView in IB with a custom text color, a bit of dummy 
>> text with a custom font, and rich text turned off (i.e., it's plain text).  
>> The problem was that when the user deletes all the text, the text view 
>> reverts to black Helvetica 12.
>
>Just did this yesterday.  Sign yourself up as the text storage's
>delegate (or listen for its
>NSTextStorageWillProcessEditingNotification) and implement
>-textStorageWillProcessEditing: to force your desired attributes.

Thanks, Kyle -- the problem is, I would have to construct a typingAttributes 
dictionary in code.  I can't grab it from the text view because the text view 
returns nil.  I prefer my workaround because it's simpler and it uses settings 
I've already selected in IB and shouldn't have to reproduce in code.  (Although 
on the other hand, the behavior I observed isn't documented, so my workaround 
could conceivably break in a future release.)

Bear in mind that in my case the text view is plain text, so I don't have the 
problem of preserving typing attributes that the user created.  Rather, I'm 
trying to get the text view to stick with the typing attributes that *I* 
created.

--Andy


___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Jesper Storm Bache
Assuming that NSString may be using CFStrings, then the issue may be  
related to const strings.

See information regarding "OTHER_CFLAGS = -fno-constant-cfstrings"

The basic issue is that when constant cfstrings is enabled, then the  
string may be put into the TEXT segment and you end up passing a  
pointer to that TEXT segment around. When the bundle/plug-in unloads  
the segment is removed from the mapped memory and you'll get a crash  
if you try to use it.
Therefore, unloadable plug-ins (that use cfstrings) should use fno- 
constant-cfstrings.


Jesper Storm Bache


On May 27, 2009, at 3:42 PM, Andy Lee wrote:

On Wednesday, May 27, 2009, at 11:48AM, "Michael Ash" > wrote:

This may seem nitpicky but I see a lot of newbies writing code just
like this. Their code is filled with stringWithString: calls for
absolutely no purpose, so I want to discourage that sort of thing.


Just for grins, I searched for calls to stringWithString: in the  
Apple examples and came across a puzzling comment in /Developer/ 
Examples/CoreAudio/AudioUnits/SampleAUs/CocoaUI/ 
SampleEffectCocoaViewFactory.m:



- (NSString *) description {
	// don't return a hard coded string (e.g.: @"Sample Effect Cocoa  
UI") because that string may be destroyed (NOT released)

// when this factory class is released.
return [NSString stringWithString:@"Sample Effect Cocoa View"];
}


It looks like an Audio Unit is some kind of pluggable module?  So  
maybe if an NSString constant had been used it would get unloaded  
when the module is unloaded -- hence the stringWithString:?


I noticed the doc for stringWithString: says that it copies the  
string's characters, so in theory it's guaranteed to create a new  
instance, unlike copy which will return the self-same instance when  
the receiver is immutable.  On the other hand, the doc for  
copyWithZone: says it returns a new instance, which it doesn't  
necessarily.  I'll file a documentation Radar about this later --  
the vast majority of the time it's an implementation detail we  
shouldn't care about, but there are times it's useful to know when a  
copy is not a copy.


--Andy



___

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

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

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

This email sent to jsba...@adobe.com


___

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

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

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

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


Re: Bindings and core data

2009-05-27 Thread Shlok Datye
The reason why IB complains is that the dot accessor only returns a  
regular set. You should therefore use "IBOutlet NSSet  
*selParticipants" instead.


For the same reason, you cannot add a participant to  
selection.participants using addObjects. Instead, you should either  
(1) use mutableSetValueForKey:@"participants" to get a genuine mutable  
set and then add your object(s) to that set; or (2) use the  
addParticipantsObject: or addParticipants: methods after properly  
declaring them.


For more information, you can read the "To-many relationships"  
subsection on this page:


http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html

Shlok Datye
Coding Turtle
http://codingturtle.com


On 27.05.2009, at 21:18, Michael Süssner wrote:


Hi
I am experimenting with core data and bindings.

I have a core data table with a one to-many relationship named  
"participants"


I have in the same view another table displaying a list of  
participants. I want to add additional participants using a  
Popuplist with contacts and a participant is related to contacts.


So, when I have selected a contact entry, I press a button which  
calls method of the PopUpMenu Controller Object, which reads the  
selected Object by


vContact = [[self selectedObjects] objectAtIndex:0];


I have defined in the PopupMenu Controller Object
IBOutlet NSMutableSet *selParticipants;

which I have bound to the table.selection.participants

(I do not understand that IB complains that it is not NSMutableSet)


Then I want to add the vContact to the selection.participants using  
addObjects but the table of participants displays invalid values.


I am not sure what is the mistake.

Michael

___

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

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

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

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


Re: Field Editor Size in NSTableView

2009-05-27 Thread Graham Cox


On 28/05/2009, at 4:15 AM, Timothy Larkin wrote:

Resizing the column makes everything good again. So there must be  
some property of the field editor that can be modified so that it  
follows the row height. Presumably this could be changed without  
resizing the column. But hours of search and experimentation have  
been in vain.



Have you tried [textEditor setVerticallyResizable:YES]; ? Seems the  
first obvious thing that springs to mind.


--Graham

___

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

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

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

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


Re: Field Editor Size in NSTableView

2009-05-27 Thread Timothy Larkin
Tried that. The field editor does vertically resize, but only if I  
change the column width. It just doesn't vertically resize in response  
to changes in the row height.


--
Timothy Larkin
Abstract Tools
Caroline, NY

On May 27, 2009, at 7:32 PM, Graham Cox wrote:

Have you tried [textEditor setVerticallyResizable:YES]; ? Seems the  
first obvious thing that springs to mind.


___

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

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

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

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


Fixing logged error that doesn't throw exception

2009-05-27 Thread Graham Cox

I'm getting this in the log when I open the "Customize Toolbar" sheet:

-[NSConcreteAttributedString initWithString:] called with nil string  
argument. This has undefined behavior and will raise an exception in  
post-Leopard linked apps. This warning is displayed only once.


Is this a bug in the frameworks or in my code? I tried setting a  
symbolic breakpoint on this but it doesn't fire at all, though if it  
did I'm not sure how I'd make it conditional on the string being nil  
as there are no debugging symbols.


It would be preferable if this did throw an exception, at least it  
could be tracked down more easily.


--Graham


___

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

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

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

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


Re: Fixing logged error that doesn't throw exception

2009-05-27 Thread Jonathan Hess
The technique I typically use to debug these types of log messages is  
a breakpoint on NSLog. If that isn't hit, you could try a breakpoint  
on write. After you hit the breakpoint, verify that it's for the log  
message you're trying to debug, and then use the backtrace to get an  
idea of what exactly is causing the log message.


Jon Hess

On May 27, 2009, at 5:15 PM, Graham Cox wrote:


I'm getting this in the log when I open the "Customize Toolbar" sheet:

-[NSConcreteAttributedString initWithString:] called with nil  
string argument. This has undefined behavior and will raise an  
exception in post-Leopard linked apps. This warning is displayed  
only once.


Is this a bug in the frameworks or in my code? I tried setting a  
symbolic breakpoint on this but it doesn't fire at all, though if it  
did I'm not sure how I'd make it conditional on the string being nil  
as there are no debugging symbols.


It would be preferable if this did throw an exception, at least it  
could be tracked down more easily.


--Graham


___

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

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

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

This email sent to jh...@apple.com


___

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

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

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

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


NSValueTransformer/Cocoa Bindings question

2009-05-27 Thread Kelvin Chung
I'm having trouble using an NSValueTransformer.  Suppose I have an  
NSArrayController foo.  If I bind a label's value to selection.number  
(which is an NSNumber) on foo, then this is fine.  However, I'm having  
trouble when it comes to transforming this value.


Suppose I have a second NSArrayController bar, whose content array  
binding is set to selection.number on foo, but with an  
NSValueTransformer transforming it into an NSArray.  However, once I  
try to test this out, I get a crash, with this:


*** Terminating app due to uncaught exception 'NSUnknownKeyException',  
reason: '[ valueForUndefinedKey:]: this class is  
not key value coding-compliant for the key number.'


Two perplexing this come to mind: the only NSTableView I have is for a  
table whose columns are bound to foo (arrangedObjects.number), which  
works normally without the binding on bar.  Second, I fail to see why  
the binding on bar fails when the binding on the label works.  The  
only thing I can think of is that there is an array key expected where  
only a single key was given.  Why is this, and how can I solve this?


___

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

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

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

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


Wacky Text View Glyph Rending Bug

2009-05-27 Thread Seth Willits


http://www.sethwillits.com/temp/TextViewGlyphBug.mov

I have a custom text storage object, and I assume that's at the core  
of this issue, but I'm not sure what's going on. Any ideas?



--
Seth Willits

___

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

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

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

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


Re: NSURLConnection sendSynchronousRequest: crashes since, upgrading to 10.5.7

2009-05-27 Thread Dennis Hartigan-O'Connor
I have a very similar problem: my simple program that downloads stock 
prices has been working fine but intermittently crashes on 10.5.7, 
whether I use sendSynchronousRequest or stringWithContentsOfURL.  For 
me, too, everything is fine for 10-15 minutes and then the program crashes.


Here is the crash log from the crashed thread:

Thread 1 Crashed:
0   libobjc.A.dylib 0x965c3688 objc_msgSend + 24
1   com.apple.CoreFoundation0x946cc581 
_CFStreamSignalEventSynch + 193
2   com.apple.CoreFoundation0x946ba595 CFRunLoopRunSpecific 
+ 3141

3   com.apple.CoreFoundation0x946bac78 CFRunLoopRunInMode + 88
4   com.apple.Foundation0x9058c530 
+[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 320

5   com.apple.Foundation0x90528e0d -[NSThread main] + 45
6   com.apple.Foundation0x905289b4 __NSThread__main__ + 308

Any ideas out there?  I can't believe this isn't happening to lots of 
people.


Dennis


cocoa-dev-requ...@lists.apple.com wrote:

Message: 1
Date: Thu, 14 May 2009 12:28:48 -0700
From: Greg Hoover 
Subject: NSURLConnection sendSynchronousRequest: crashes since
upgrading to10.5.7
To: Cocoa Developers 
Message-ID: <9dc8f25a-ff9e-46d9-8725-d520d35c2...@greg-web.net>
Content-Type: text/plain;   charset=US-ASCII;   format=flowed;  
delsp=yes

After upgrading to 10.5.7 I've been having intermittent trouble with  
deallocated objects in NSURLConnections.  All of my URL requests are  
made using sendSynchronousRequest.  Everything is fine for about 10-15  
minutes, then I get this crash.  I am making requests on multiple  
threads, obviously only one at a time per thread though since they're  
synchronous.


  *** -[CFArray count]: message sent to deallocated instance 0x27eb6950
*** NSInvocation: warning: object 0x27eb6950 of class  
'_NSZombie_CFArray' does not implement methodSignatureForSelector: --  
trouble ahead


#0  0x90718640 in ___forwarding___
#1  0x90718972 in __forwarding_prep_0___
#2  0x90627da1 in CFArrayGetCount
#3  0x906ab581 in _CFStreamSignalEventSynch
#4  0x90699595 in CFRunLoopRunSpecific
#5  0x90699c78 in CFRunLoopRunInMode
#6	0x9468f530 in +[NSURLConnection(NSURLConnectionReallyInternal)  
_resourceLoadLoop:]

#7  0x9462be0d in -[NSThread main]
#8  0x9462b9b4 in __NSThread__main__
#9  0x94365155 in _pthread_start
#10 0x94365012 in thread_start

Any insight would be great,
Greg

___

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

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

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

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


Re: Wacky Text View Glyph Rending Bug

2009-05-27 Thread Aki Inoue

Looks like the glyph info stored in NSLayoutManager is out of sync.

Are you calling -edited:range:changeInLength: from your implementation  
of attribute modifying methods ?


Aki

On 2009/05/27, at 18:19, Seth Willits wrote:



http://www.sethwillits.com/temp/TextViewGlyphBug.mov

I have a custom text storage object, and I assume that's at the core  
of this issue, but I'm not sure what's going on. Any ideas?



--
Seth Willits

___

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

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

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

This email sent to a...@apple.com


___

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

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

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

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


Re: Fixing logged error that doesn't throw exception

2009-05-27 Thread Ken Thomases

On May 27, 2009, at 7:15 PM, Graham Cox wrote:


I'm getting this in the log when I open the "Customize Toolbar" sheet:

-[NSConcreteAttributedString initWithString:] called with nil  
string argument. This has undefined behavior and will raise an  
exception in post-Leopard linked apps. This warning is displayed  
only once.


Is this a bug in the frameworks or in my code?


Probably your code.  Presumably Apple has tried to eliminate all  
instances of this bug in their own code.


I tried setting a symbolic breakpoint on this but it doesn't fire at  
all, though if it did I'm not sure how I'd make it conditional on  
the string being nil as there are no debugging symbols.


You could test the location on the stack which holds the parameter.   
On x86, that's:


*(id*)($ebp + 16)

You can also use DTrace:

sudo dtrace -n 'objc$target:NS*AttributedString:initWithString?:entry / 
arg2==0/ {ustack();}' -p 


(arg0 is 'self', arg1 is '_cmd', so arg2 is the first non-hidden  
method parameter.)


Cheers,
Ken

___

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

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

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

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


Re: Abstract class with single subclass

2009-05-27 Thread Michael Ash
On Wed, May 27, 2009 at 5:37 PM, Seth Willits  wrote:
> I know this isn't exactly a very detailed description, but if they were
> equivalent, then changing [self class] to self shouldn't have fixed it, but
> it did. Pretty weird.

Does not follow. It's quite common in C-based languages to have broken
code which only manifests bugs in a certain machine context. (For
example, reading from unintialized memory.) Code which is logically
equivalent will not necessarily generate the same machine code, thus
you can have two pieces of logically equivalent code but only have one
of them set you up for a crash due to a bug elsewhere.

Mike
___

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

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

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

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


Re: Fixing logged error that doesn't throw exception

2009-05-27 Thread Graham Cox


On 28/05/2009, at 11:40 AM, Ken Thomases wrote:


On May 27, 2009, at 7:15 PM, Graham Cox wrote:

I'm getting this in the log when I open the "Customize Toolbar"  
sheet:


-[NSConcreteAttributedString initWithString:] called with nil  
string argument. This has undefined behavior and will raise an  
exception in post-Leopard linked apps. This warning is displayed  
only once.


Is this a bug in the frameworks or in my code?


Probably your code.  Presumably Apple has tried to eliminate all  
instances of this bug in their own code.



Agreed - though see below.

I tried setting a symbolic breakpoint on this but it doesn't fire  
at all, though if it did I'm not sure how I'd make it conditional  
on the string being nil as there are no debugging symbols.


You could test the location on the stack which holds the parameter.   
On x86, that's:


*(id*)($ebp + 16)


Ah, thanks! It's been a while and I'd forgotten how to use that  
approach. OK, I got it to break. Here's the stack trace. Appears to be  
entirely framework code. My toolbar is entirely constructed within IB  
using standard items with nothing apparently tricky going on - just  
toolbar buttons hooked to actions. The error is logged when the  
"Customise Toolbar" dialog is invoked. If it still could be my code,  
any pointers as to where I should look? It appears to be attempting to  
copy a text field by archiving it. The only field I have in the  
toolbar is a search field - looks entirely standard as far as I can see.


#0  0x93d221e6 in -[NSConcreteAttributedString initWithString:]
#1	0x93d220eb in -[NSConcreteAttributedString  
initWithString:attributes:]
#2	0x93d3c673 in -[NSNumberFormatter(NSNumberFormatterCompatibility)  
attributedStringForZero]

#3  0x93e4e97d in -[NSNumberFormatter encodeWithCoder:]
#4  0x93d2d39d in _encodeObject
#5  0x94e855bd in -[NSCell encodeWithCoder:]
#6  0x94e84fb3 in -[NSActionCell encodeWithCoder:]
#7  0x94e84deb in -[NSTextFieldCell encodeWithCoder:]
#8  0x93d2d39d in _encodeObject
#9  0x94e84da9 in -[NSControl encodeWithCoder:]
#10 0x94e84b76 in -[NSTextField encodeWithCoder:]
#11 0x93d2d39d in _encodeObject
#12 0x93d9dbed in -[NSKeyedArchiver _encodeArrayOfObjects:forKey:]
#13 0x93d4d5b7 in -[NSArray(NSArray) encodeWithCoder:]
#14 0x93d2d39d in _encodeObject
#15 0x94e83ec8 in -[NSView encodeWithCoder:]
#16 0x93d2d39d in _encodeObject
#17 0x93d9dbed in -[NSKeyedArchiver _encodeArrayOfObjects:forKey:]
#18 0x93d4d5b7 in -[NSArray(NSArray) encodeWithCoder:]
#19 0x93d2d39d in _encodeObject
#20 0x94e83ec8 in -[NSView encodeWithCoder:]
#21 0x9503fae5 in -[NSBox encodeWithCoder:]
#22 0x93d2d39d in _encodeObject
#23 0x93d2cb18 in +[NSKeyedArchiver archivedDataWithRootObject:]
#24 0x9527a38d in -[NSToolbarItem _copyOfCustomView]
#25 0x9527a44c in -[NSToolbarItem copyWithZone:]
#26 0x9718c05a in -[NSObject copy]
#27	0x94e16da2 in -[NSToolbar  
_newItemFromItemIdentifier:requireImmediateLoad:willBeInsertedIntoToolbar 
:]
#28	0x952748e2 in -[NSToolbar  
toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:]
#29	0x94e19d80 in -[NSToolbar  
_newItemFromDelegateWithItemIdentifier:willBeInsertedIntoToolbar:]
#30	0x94e16dfe in -[NSToolbar  
_newItemFromItemIdentifier:requireImmediateLoad:willBeInsertedIntoToolbar 
:]
#31	0x94e16bed in -[NSToolbar  
_insertNewItemWithItemIdentifier:atIndex:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults 
:]
#32	0x94e6fea4 in -[NSToolbar  
_appendNewItemWithItemIdentifier:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults 
:]
#33	0x94e187cb in -[NSToolbar  
_setCurrentItemsToItemIdentifiers:notifyDelegate:notifyView:notifyFamilyAndUpdateDefaults 
:]
#34	0x95272abf in -[NSToolbar  
_loadInitialItemIdentifiers:requireImmediateLoad:]

#35 0x95277f2a in -[NSToolbarConfigPanel _loadData]
#36 0x95277921 in -[NSToolbarConfigPanel initForToolbar:withWidth:]
#37 0x95273019 in -[NSToolbar _runCustomizationPanel]
#38 0x94e9c524 in -[NSToolbarButton sendAction:to:]
#39 0x94e9c4b5 in -[NSToolbarButton sendAction]
#40 0x94e9ba36 in -[NSToolbarItemViewer mouseDown:]
#41 0x94d56133 in -[NSWindow sendEvent:]
#42 0x94d22cd9 in -[NSApplication sendEvent:]
#43 0x94c8062f in -[NSApplication run]
#44 0x94c4d834 in NSApplicationMain

___

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

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

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

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


Re: stripping question

2009-05-27 Thread Eric Slosser


On May 27, 2009, at 6:39 PM, Kyle Sluder wrote:

On Wed, May 27, 2009 at 1:35 PM, Eric Slosser fx.com> wrote:

Why is this symbol required to launch?


Does MyController have an +initialize method,


No.


or does any other
class's +initialize method possibly create an instance of or call a
class method of MyController?


Not that I can see.   The only way I see a MyController being  
instantiated at launch is through the XIB files, but removing those  
didn't affect the crash.

___

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

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

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

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


Re: Fixing logged error that doesn't throw exception

2009-05-27 Thread Dave Keck
I see this error at least several times a week. Searching through this
week's logs from my work computer:

ibtool[6341]: -[NSConcreteAttributedString initWithString:] called
with nil string argument...
mdworker[422]: -[NSConcreteAttributedString initWithString:] called
with nil string argument...

Both being Apple-supplied utilities.

David
___

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

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

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

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


Re: Fixing logged error that doesn't throw exception [SOLVED]

2009-05-27 Thread Graham Cox


On 28/05/2009, at 12:04 PM, Graham Cox wrote:

The only field I have in the toolbar is a search field - looks  
entirely standard as far as I can see.


#0  0x93d221e6 in -[NSConcreteAttributedString initWithString:]
#1	0x93d220eb in -[NSConcreteAttributedString  
initWithString:attributes:]
#2	0x93d3c673 in -[NSNumberFormatter(NSNumberFormatterCompatibility)  
attributedStringForZero]



Right, found the problem. It was sort of my fault (did anyone expect  
anything else?) but then again maybe not. Turns out there was another  
field in the toolbar with an attached formatter that I'd overlooked,  
and its fields for zero and nil were not set up. This is the default  
state for a formatter when you add one in IB. But it seems that these  
entries MUST be there to avoid this error if the formatter lives  
inside a toolbar item.


Would be nice if a formatter (or IB) would initialise these fields to  
something valid.


Should I log this as a framework/IB bug, or did I have it coming to me?

--Graham
___

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

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

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

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


Re: Wacky Text View Glyph Rending Bug

2009-05-27 Thread Seth Willits


So I just stripped the entire project down to 60 lines of code and it  
was still happening. I was JUST about to click send and then I re-read  
your message, and it turns out I forgot to call  - 
edited:range:changeInLength: from within -setAttributes:range:


Added that one line and all is good.


Thanks,

--
Seth Willits




On May 27, 2009, at 6:27 PM, Aki Inoue wrote:


Looks like the glyph info stored in NSLayoutManager is out of sync.

Are you calling -edited:range:changeInLength: from your  
implementation of attribute modifying methods ?


Aki

On 2009/05/27, at 18:19, Seth Willits wrote:



http://www.sethwillits.com/temp/TextViewGlyphBug.mov

I have a custom text storage object, and I assume that's at the  
core of this issue, but I'm not sure what's going on. Any ideas?



___

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

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

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

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


How determine if file is in Trash, given Path or Alias

2009-05-27 Thread Jerry Krinock
How can I determine if a given file path, or a file alias (I have  
both), refers to an item which is in the Trash?


The obvious answer, using -[NSString hasPrefix:] on the path with  
NSHomeDirectory()/.Trash, doesn't look very pretty.


Thanks,

Jerry
___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Andy Lee
I just noticed an earlier message in this thread that points out that  
stringWithString: does in fact do the same optimization as -copy for  
constant strings.  So the approach in Apple's sample code does not  
protect from the bundle unloading problem.  Aside from the  
OTHER_CFLAGS approach Jesper describes, the only solution I can think  
of is to use [NSMutableString stringWithString:] instead of [NSString  
stringWithString:].


But of course this is an odd case, and the vast majority of the time  
it's just wasted code to say stringWithString:@"abc".


--Andy


On May 27, 2009, at 7:11 PM, Jesper Storm Bache wrote:

Assuming that NSString may be using CFStrings, then the issue may be  
related to const strings.

See information regarding "OTHER_CFLAGS = -fno-constant-cfstrings"

The basic issue is that when constant cfstrings is enabled, then the  
string may be put into the TEXT segment and you end up passing a  
pointer to that TEXT segment around. When the bundle/plug-in unloads  
the segment is removed from the mapped memory and you'll get a crash  
if you try to use it.
Therefore, unloadable plug-ins (that use cfstrings) should use fno- 
constant-cfstrings.


Jesper Storm Bache


On May 27, 2009, at 3:42 PM, Andy Lee wrote:

On Wednesday, May 27, 2009, at 11:48AM, "Michael Ash" > wrote:

This may seem nitpicky but I see a lot of newbies writing code just
like this. Their code is filled with stringWithString: calls for
absolutely no purpose, so I want to discourage that sort of thing.


Just for grins, I searched for calls to stringWithString: in the  
Apple examples and came across a puzzling comment in /Developer/ 
Examples/CoreAudio/AudioUnits/SampleAUs/CocoaUI/ 
SampleEffectCocoaViewFactory.m:



- (NSString *) description {
	// don't return a hard coded string (e.g.: @"Sample Effect Cocoa  
UI") because that string may be destroyed (NOT released)

// when this factory class is released.
return [NSString stringWithString:@"Sample Effect Cocoa View"];
}


It looks like an Audio Unit is some kind of pluggable module?  So  
maybe if an NSString constant had been used it would get unloaded  
when the module is unloaded -- hence the stringWithString:?


I noticed the doc for stringWithString: says that it copies the  
string's characters, so in theory it's guaranteed to create a new  
instance, unlike copy which will return the self-same instance when  
the receiver is immutable.  On the other hand, the doc for  
copyWithZone: says it returns a new instance, which it doesn't  
necessarily.  I'll file a documentation Radar about this later --  
the vast majority of the time it's an implementation detail we  
shouldn't care about, but there are times it's useful to know when  
a copy is not a copy.


--Andy



___

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

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

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

This email sent to jsba...@adobe.com




___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-05-27 Thread Kiel Gillard

Nothing comes to mind from the top of my head.

A little digging through Carbon documentation suggested you could use  
FSCatalogInfo() function to determine the parent directory ID of the  
file you are testing. With the result of that function, you can use  
the IdentifyFolder() function to see if the parent directory's folder  
type == kSystemTrashFolderType.


Hope this helps,

Kiel

On 28/05/2009, at 1:05 PM, Jerry Krinock wrote:

How can I determine if a given file path, or a file alias (I have  
both), refers to an item which is in the Trash?


The obvious answer, using -[NSString hasPrefix:] on the path with  
NSHomeDirectory()/.Trash, doesn't look very pretty.


Thanks,

Jerry
___

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

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

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

This email sent to kiel.gill...@gmail.com


___

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

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

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

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


Re: NSString initWithFormat and stringWith

2009-05-27 Thread Bill Bumgarner

On May 27, 2009, at 8:20 PM, Andy Lee wrote:
I just noticed an earlier message in this thread that points out  
that stringWithString: does in fact do the same optimization as - 
copy for constant strings.  So the approach in Apple's sample code  
does not protect from the bundle unloading problem.  Aside from the  
OTHER_CFLAGS approach Jesper describes, the only solution I can  
think of is to use [NSMutableString stringWithString:] instead of  
[NSString stringWithString:].


But of course this is an odd case, and the vast majority of the time  
it's just wasted code to say stringWithString:@"abc".


If you find something that is causing a bundle with Objective-C code  
to be unloaded, please file a bug via http://bugreport.apple.com/.


It isn't supported and the number of edge cases are both vast and  
subtle to the point of "it just does not work, don't do it.".


(And it really won't work with GC turned on)

b.bum

___

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

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

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

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


Re: [NSApp presentError:error] & Custom Icon ...

2009-05-27 Thread Jerry Krinock


On 2009 May 19, at 07:53, Mic Pringle wrote:


Is it possible to use an icon other than the applications when using
[NSApp presentError:error] ?


Override -willPresentError: like this:

- (NSError *)willPresentError:(NSError *)error_ {
// Present the error yourself
... [beginSheet..., show alert, whatever

// This will stop Cocoa from presenting the error:
return [NSError errorWithDomain:NSCocoaErrorDomain
   code:NSUserCancelledError
   userInfo:nil]  ;
}

I would like to say "Never allow Cocoa present an error in a shipping  
app."  Besides the fact that Cocoa's boldface presentation is ugly, it  
isn't even any good for development, because it discards all of the  
goodies you or Cocoa have put into the error's userInfo dictionary.   
You'd be amazed that sometimes there's actually an explanation beneath  
"Core Data could not fulfill a fault"!


___

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

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

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

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


Re: Core data, bindings and multiple view NIB

2009-05-27 Thread Tomaž Kragelj
Thanks Keary, this works, however it requires that the same binding is  
repeated in each nib where the same list should be handled (some views  
may only need to show it while others can also modify it). I was  
thinking of creating a "master" set of controllers in the main nib,  
then bind the "slave" controllers in particular view nib file to the  
values from the corresponding master controller. Is that possible, or  
is it not how bindings should be used?


Tom

On 27.5.2009, at 22:43, Keary Suska wrote:


On May 27, 2009, at 12:30 AM, Tomaž Kragelj wrote:


GroupItemsController:
- managed object context -> Application.delegate.managedObjectContext
- ???
The question marks are what I'm missing - if I don't bind to  
anything, then the array controller will simply show all items for  
all groups, however I want to bind this to the GroupItemsController  
from the MainMenu.nib (it is accessible through the  
Application.delegate, but I don't know how to bind it in order to  
show only the items selected by the group in GroupsView.nib...


Have you tried Application.delegate.GroupController.selection.items  
(the last key os whatever relationship you need to use)?


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

___

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

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

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

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


___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-05-27 Thread Adam R. Maxwell

On May 27, 2009, at 8:05 PM, Jerry Krinock wrote:

How can I determine if a given file path, or a file alias (I have  
both), refers to an item which is in the Trash?


The obvious answer, using -[NSString hasPrefix:] on the path with  
NSHomeDirectory()/.Trash, doesn't look very pretty.


Check the docs for FSDetermineIfRefIsEnclosedByFolder, which uses a  
specific example of a trash folder.





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Creating, Constructing and Managing Dynamic (Sub)Views

2009-05-27 Thread Grant Erickson
I have a set of, let's say three, devices that have a range features among
them: a common, base feature set and then some combination of A, B or A + B
on top of that common base.

When the user is managing and configuring these devices from a list (a table
view for example), I bring up a dialog box that allows the user to configure
the device and the features:

 .-.
 | O O O   Window/Sheet/Panel  |
 |-|
 | |
 | Common  |
 |Features |
 |&|
 |  Configuration  |
 | |
 |- -- -- - -- -- - -- -- - -- -- - -- -- - -- -- - -- -- - -- -- -|
 |||
 |  Feature Set A .  Feature Set B |
 |  Configuration .  Configuration |
 |||
 |- -- -- - -- -- - -- -- - -- -- - -- -- - -- -- - -- -- - -- -- -|
 | |
 | .--.   .--.  .. .---.  .--. |
 | | Previous |   | Next |  | Cancel | | Apply |  |  OK  | |
 | '--'   '--'  '' '---'  '--' |
 !_!

Right now, I realize the view with a controller for a single device with:

typedef boost::shared_ptr FooBaseDevicePointer;
typedef std::vector FooBaseDeviceCollection;

+ (FooDeviceSettingsController *) withDevice: (FooBaseDevicePointer
&)inDevice;
- (id) initWithDevice: (FooBaseDevicePointer &)inDevice;

or for multiple devices with:

+ (FooDeviceSettingsController *) withDevices: (FooBaseDeviceCollection
&)inDevices;
- (id) initWithDevices: (FooBaseDeviceCollection &)inDevices;

and then just disable features and options not available for a given device
when the view is instantiated and as the user cycles through "previous" or
"next".

However to avoid user confusion and frustration over greyed-out (i.e.
disabled) features they can't seem to access or enable, what I'd rather do
is have a series of (sub)views for each feature subset. In effect, there'd
be a device-specific view (say DeviceXSettingsView, DeviceYSettingsView and
DeviceZSettings) for each device and that view is a has-a-view composition
among the common, A and B (sub)views:

DeviceXSettingsView
has-a CommonFeatureView

DeviceYSettingsView
has-a CommonFeatureView
has-a FeatureAView

DeviceZSettingsView
has-a CommonFeatureView
has-a FeatureAView
has-a FeatureBView

In the absence of one subview or another, the super view and sub views would
adjust accordingly (common snaps down to the buttons in the absence of A and
B, A fills right in the absence of B, B snaps right in the absence of A,
etc.).

I think it's pretty straightforward how to do this programmatically;
however, it seems like I should be able to avoid that and do 90% of the work
in Interface Builder. Basically, establish a custom view class for each of
the above described subviews (CommonFeatureView, FeatureAView,
FeatureBView), a NIB in IB for each using those custom view classes. If I
can do this, is it best to have a NIB for each subview or pack them all into
a single NIB? Six of one; half dozen of the other?

I suspect I could also do this by adding/removing tabs and having a view for
each. Unfortunately, the base case of one tab (which ostensibly should just
be a box) seems like bad user interface form.

Are there any good URLs, books or code samples (Apple or otherwise) that
anyone can recommend that demonstrate this sort of thing? I've not yet come
across one in /Developer/Examples/... that seems similar enough in scope.

Thanks,

Grant


___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-05-27 Thread Jerry Krinock
Thanks, Kiel and Adam.  FSDetermineIfRefIsEnclosedByFolder() has the  
advantage over IdentifyFolder(parent) of working for items that are  
buried in folders that are in the trash, but strangely it gives a -35  
nsvErr "no such volume" error if the item is not in the trash.  I just  
ignore all the errors anyhow, since, for example, if a file is "not  
found", it's obviously "not in the trash".


At first I thought these FS functions were in Carbon, but the docs say  
that they are in CoreServices, so I guess this is OK for the 64-bit  
future.



BOOL isInTrash(NSString* path) {
FSRef fsRef;
Boolean result = false ;
OSStatus err = FSPathMakeRef(
 (UInt8*)[path UTF8String],
 &fsRef,
 NULL) ;
if (err == noErr) {
FolderType folderType ;
FSDetermineIfRefIsEnclosedByFolder (
kOnAppropriateDisk,
kTrashFolderType,
&fsRef,
&result
) ;
}

return (result == true) ;
}


___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-05-27 Thread Kyle Sluder
On Wed, May 27, 2009 at 10:04 PM, Jerry Krinock  wrote:
> At first I thought these FS functions were in Carbon, but the docs say that
> they are in CoreServices, so I guess this is OK for the 64-bit future.

The only parts of Carbon that are deprecated are the GUI aspects.
While it makes sense to avoid linking to Carbon.framework in order to
avoid dragging in all of it, you'll be fine with the non-GUI stuff for
the foreseeable future.

--Kyle Sluder
___

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

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

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

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


Programmatically displaying NSStatusItem's menu

2009-05-27 Thread Adam Warski

Hello,

I have a simple NSStatusItem with a menu (no custom views), just using  
text as the title.
When I click on it, everything displays fine, however now I would like  
to display it programmatically - in other words, simulate a mouse  
click on the status item's text.
Currently I'm invoking "popUpStatusItemMenu", and this shows the menu,  
but doesn't highlight the title.


How could I highlight the title? Or maybe there's a better way to  
simulate the mouse click?


--
Thanks,
Adam
___

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

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

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

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


Re: Creating, Constructing and Managing Dynamic (Sub)Views

2009-05-27 Thread Graham Cox


On 28/05/2009, at 2:34 PM, Grant Erickson wrote:


is it best to have a NIB for each subview or pack them all into
a single NIB?



I'd say put all the subviews into the same nib. It makes it much  
easier to select among them because you can have a single master  
controller that has outlets for each subcontroller. You can also  
instantiate each subcontroller in the nib and connect up all the  
individual controls for each subview.


Switching them in and out could be done with a tabless tabview, but  
it's also very easy to write code that inserts and removes the  
subviews. This code can be made generic and not requiring modification  
if you add further types of subview by choosing a naming convention  
for your outlets and taking advantage of valueForKey:'s ability to  
discover ivars by name.


KVO and bindings can further reduce the code needed to implement the  
view/controller handling. With care it can be boiled down to just a  
few lines of code.


--Graham




___

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

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

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

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


Booleans

2009-05-27 Thread John Ku
I am trying to set an object's boolean, everything works but I get a warning
of 'pointer from integer without a cast'.
*//  Here is the Main Class:*
[theObject setActivated: YES];

*//  Here is the Object Class:*
@property(readwrite, assign) BOOL *activated;
@synthesize activated;

- (void) setActivated: (BOOL *) boolean {
  activated = boolean;
}


The weird thing is that if i setActivated: NO, it would not give any warning
or error. Only When I setActivated: YES i get this:
"warning: passing argument 1 of 'setActivated:' makes pointer from integer
without a cast"

Anyone know what's wrong?

Thanks,

John
___

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

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

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

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


Re: Booleans

2009-05-27 Thread Roland King

BOOL isn't an object. you want BOOL not BOOL*

John Ku wrote:

I am trying to set an object's boolean, everything works but I get a warning
of 'pointer from integer without a cast'.
*//  Here is the Main Class:*
[theObject setActivated: YES];

*//  Here is the Object Class:*
@property(readwrite, assign) BOOL *activated;
@synthesize activated;

- (void) setActivated: (BOOL *) boolean {
  activated = boolean;
}


The weird thing is that if i setActivated: NO, it would not give any warning
or error. Only When I setActivated: YES i get this:
"warning: passing argument 1 of 'setActivated:' makes pointer from integer
without a cast"

Anyone know what's wrong?

Thanks,

John
___

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

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

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

This email sent to r...@rols.org

___

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

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

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

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


Re: Booleans

2009-05-27 Thread John Ku
Thank you all, a newb mistake. :PIm going crazy trying to put pointer on
everything.

Btw, BOOL is not, is Boolean a pointer type?

Thanks!

On Wed, May 27, 2009 at 11:46 PM, Roland King  wrote:

> BOOL isn't an object. you want BOOL not BOOL*
>
> John Ku wrote:
>
>> I am trying to set an object's boolean, everything works but I get a
>> warning
>> of 'pointer from integer without a cast'.
>> *//  Here is the Main Class:*
>> [theObject setActivated: YES];
>>
>> *//  Here is the Object Class:*
>> @property(readwrite, assign) BOOL *activated;
>> @synthesize activated;
>>
>> - (void) setActivated: (BOOL *) boolean {
>>  activated = boolean;
>> }
>>
>>
>> The weird thing is that if i setActivated: NO, it would not give any
>> warning
>> or error. Only When I setActivated: YES i get this:
>> "warning: passing argument 1 of 'setActivated:' makes pointer from integer
>> without a cast"
>>
>> Anyone know what's wrong?
>>
>> Thanks,
>>
>> John
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org
>>
>> This email sent to r...@rols.org
>>
>
___

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

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

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

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