On 9 May 2012, at 19:55, Corbin Dunn wrote:

>> , so probably that is causing the issue then. To make it possible to have an 
>> empty text field when there are no pages in the document I changed the 
>> symbol for 0:
>>      [self.toolbarPageNumberTextField.formatter setZeroSymbol:@""]; (I did 
>> not know this is possible, until a few minutes ago.)
> 
>> 
>> Then changed all instances of:
>>                              self.toolbarPageNumberTextField.stringValue = 
>> @"";
>> 
>> to
>>                              self.toolbarPageNumberTextField.stringValue = 
>> @"0";
>> 
> 
> Did that fix the problem? 

I think it did. Still need to confirm with the person who initially alerted me 
to the issue, but I can no longer make it crash.

>> Following your recommendation I also changed
>>                                      
>> self.toolbarPageNumberTextField.integerValue = 
>> self.pageListController.selectionIndex + 1;
>> to
>>                                      
>> self.toolbarPageNumberTextField.stringValue = [NSString 
>> stringWithFormat:@"%d", self.pageListController.selectionIndex + 1];
>> 
>> Why do you recommend against using integerValue? For me it would make more 
>> sense to always use integerValue, especially now that I can set the value to 
>> 0 to show an empty text field, since we're conceptually representing numbers 
>> here, not strings.
> 
> Well, it is just more consistent if you treat it all the same. Plus, when you 
> read the integerValue, what NSCell doe is creates an NSScanner and scans the 
> string (in the cell) for an integer and returns that value. This creates a 
> scanner with your current locale...which may or may not be what you want (it 
> probably is). When you call setIntegerValue it sets the objectValue of the 
> cell to be an NSNumber. It really isn't an issue, but it just flip-flops the 
> value type from a string to an integer back and forth. 

Thanks for explaining that so clearly Corbin.

-António

----------------------------------------------------
It is better to light a candle than to curse the darkness
----------------------------------------------------




_______________________________________________

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

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

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

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

Reply via email to