Re: Keeping a menu enabled with a modal dialog running

2012-10-28 Thread Kyle Sluder
On Oct 28, 2012, at 3:40 PM, Graham Cox  wrote:

> Hi all,
> 
> I have a menu item that should be available in my app no matter what. 
> Currently its target is the app delegate and it does not go through First 
> Responder. However, it is greyed out when a modal dialog is running which is 
> annoying. Is there a way to ensure that such a menu can still be responded to 
> (enabled) when the modal dialog is up?

You may need to turn off autoenablesItems on your menu, add your app delegate 
as the menu's delegate, and implement -menuNeedsUpdate: to replicate the 
default logic except in the case of your always-enabled menu item.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Keeping a menu enabled with a modal dialog running

2012-10-28 Thread Graham Cox
Hi all,

I have a menu item that should be available in my app no matter what. Currently 
its target is the app delegate and it does not go through First Responder. 
However, it is greyed out when a modal dialog is running which is annoying. Is 
there a way to ensure that such a menu can still be responded to (enabled) when 
the modal dialog is up?

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: variable problem is driving me nuts

2012-10-28 Thread Kyle Sluder
On Oct 28, 2012, at 12:01 PM, Jens Alfke  wrote:

> 
> On Oct 28, 2012, at 1:37 AM, Kyle Sluder  wrote:
> 
>>> In general, initialization code like this in a nib-loaded object should go 
>>> into its -awakeFromNib method, which is [almost] guaranteed to be the first 
>>> method invoked on that object.
>> 
>> Actually, the NSTableView docs explicitly warn that this is not the case:
> 
> That’s why I said “[almost]”. :)

Well, it's contraindicated enough that I try to never do it.

> 
>> Initialize your instance variable in -init, which *is* guaranteed to be the 
>> first method called on your object.
> 
> I didn’t think init methods were called for objects loaded from nibs? (It’s 
> possible this may have changed over time, though, since the old days when I 
> learned Cocoa coding on the street from Buggsy and Leroy.)

The Resource Programming Guide has the details, but in summary: on OS X, Custom 
Objects are initialized with -init, Custom Views are initialized with 
-initWithFrame:, and everything else is initialized with -initWithCoder:.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: variable problem is driving me nuts

2012-10-28 Thread gweston

H Miersch wrote: 

then why does Xcode complain about an unused result? this is just another example of a TOTALLY USELESS error message. 


anyway, i fixed it, and now it works. thanks.


ok, it looks like i've sorted the original problem. but here's the next one:

i have this line:

for (i = 0; i++; i < count) {…}

in the app delegate. Xcode keeps giving me this warning: expression result 
unused. WTF? that is correct syntax for a for loop, isn't it? so then why do i 
keep getting this warning?
also, i have confirmed that the statements between { and } are NOT executed, no 
matter what. that's not right either. so WTF is going on here?
___


no it's not even vaguely the right syntax for a for loop. You have 
for( initialiser, iterator, condition )
it's supposed to be 
for( initialiser, condition, iterator )

that's just basic C

 

The problem is that while it's not, as the prior poster indicated, the right 
syntax for a working for loop it's not actually illegal syntax in general. 
for(a;b;c) {d} means precisely:

a; while(b != 0) { d; c; }

Your original code is perfectly legal if you consider it that way. It just 
wasn't doing what you wanted.

And why was your code never executing?

Because i++ evaluates to i and *then* increments i in place. Since i was zero 
on the first pass it bailed out immediately. If you had used ++i instead, it 
would've run through the entire space of whatever type i is.

___

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

Please do not post 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

Re: Warning message using stringWithContentsOfFile:encoding:error:

2012-10-28 Thread gweston

Quincey Morris wrote


No matter what you do, file a bug with the 3rd-party framework. Their macros 
should not leak.


The thing that bothers me is why macros should be substituting into method 
parameter names at all. It potentially brings *pieces* of method names into the 
global symbol namespace -- which is basically what happened to Paul, if you 
look at his problem from the other end. That possibility seems nightmarish to 
me.
 
That's what macros do. C's #define mechanism is only slightly more than a 1:1 string 
replacement directive. If the #define X Y means that if the preprocessor sees X as a 
token it replaces it with Y. It has no concept of things like method or function names in 
the "real" language. It supports arguments in its own context, but that's about 
it.

One of the more amusing entries in the international obfuscated C contest many 
years ago was a source file consisting of a single letter. The rules were 
amended the next year to say that macros counted against the size restriction.


___

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

Please do not post 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

Re: Warning message using stringWithContentsOfFile:encoding:error:

2012-10-28 Thread Jens Alfke

On Oct 28, 2012, at 11:03 AM, Quincey Morris 
 wrote:

> The thing that bothers me is why macros should be substituting into method 
> parameter names at all.

The preprocessor barely knows anything about C syntax, let alone Obj-C. 
Remember, it’s running before the parser — all it gets is a stream of tokens. 
It just sees an identifier followed by a “:”, and there’s a macro defined for 
that identifier, so it substitutes it.

> It potentially brings *pieces* of method names into the global symbol 
> namespace -- which is basically what happened to Paul, if you look at his 
> problem from the other end. That possibility seems nightmarish to me.

“Nightmarish” is a pretty good description of the malign possibilities of the C 
preprocessor in general. :-P

—Jens
___

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

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

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

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

Re: variable problem is driving me nuts

2012-10-28 Thread Jens Alfke

On Oct 28, 2012, at 1:37 AM, Kyle Sluder  wrote:

>> In general, initialization code like this in a nib-loaded object should go 
>> into its -awakeFromNib method, which is [almost] guaranteed to be the first 
>> method invoked on that object.
> 
> Actually, the NSTableView docs explicitly warn that this is not the case:

That’s why I said “[almost]”. :)

> Initialize your instance variable in -init, which *is* guaranteed to be the 
> first method called on your object.

I didn’t think init methods were called for objects loaded from nibs? (It’s 
possible this may have changed over time, though, since the old days when I 
learned Cocoa coding on the street from Buggsy and Leroy.)

—Jens
___

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

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

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

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

Re: Warning message using stringWithContentsOfFile:encoding:error:

2012-10-28 Thread Quincey Morris
On Oct 28, 2012, at 10:37 , Kyle Sluder  wrote:

> No matter what you do, file a bug with the 3rd-party framework. Their macros 
> should not leak.

The thing that bothers me is why macros should be substituting into method 
parameter names at all. It potentially brings *pieces* of method names into the 
global symbol namespace -- which is basically what happened to Paul, if you 
look at his problem from the other end. That possibility seems nightmarish to 
me.


___

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

Please do not post 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


Re: Warning message using stringWithContentsOfFile:encoding:error:

2012-10-28 Thread Kyle Sluder
On Oct 28, 2012, at 10:23 AM, Paul Johnson  wrote:

> Thanks, Nick and Gary. You are absolutely right. I found 'error' is being
> defined in a 3rd-party framework I'm using.
> 
> Then there is the question of how to work around this, so I can use the
> NSString class method. If you can suggest a solution I would be grateful.

In order of decreasing simplicity:

1. Don't include the errant header file from your source code.

2. Modify the header file to #undefine error at the end.

3. #undefine error in places you include the header file from.

No matter what you do, file a bug with the 3rd-party framework. Their macros 
should not leak.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Warning message using stringWithContentsOfFile:encoding:error:

2012-10-28 Thread Paul Johnson
Thanks, Nick and Gary. You are absolutely right. I found 'error' is being
defined in a 3rd-party framework I'm using.

Then there is the question of how to work around this, so I can use the
NSString class method. If you can suggest a solution I would be grateful.


On Sat, Oct 27, 2012 at 7:41 PM, Gary L. Wade
wrote:

> What you think you're calling is the NSString class method
> +stringWithContentsOfFile:encoding:error: but due to an unexpected
> definition, you're actually calling the NSString class method
> +stringWithContentsOfFile:encoding:Rf_error: Apple does not have a publicly
> defined selector of that name, so that's why you're getting that warning.
> What you need to find is where "error" is being defined, not Rf_error.
> Because C provides for concatenation using the ## operator, you may not
> find that string. I'm guessing you're using someone else's headers,
> framework, or project, possible where error is redefined for some purpose,
> possibly debugging or mapping to another set of code.
> --
> Gary L. Wade (Sent from my iPad)
> http://www.garywade.com/
>
> On Oct 27, 2012, at 4:21 PM, Paul Johnson  wrote:
>
> > Nick, I can't find any headers that #define 'Rf_error'.
> >
> > The warning message seems to be complaining about assigning to the type
> > 'NString *' when type 'id' is expected, though.
> >
> > I'm not sure where Rf_error is defined, but it must be in the Cocoa
> headers.
> >
> > Thanks for your reply.
> >
> > On Sat, Oct 27, 2012 at 5:37 PM, Nick Zitzmann 
> wrote:
> >
> >>
> >> On Oct 27, 2012, at 4:04 PM, Paul Johnson  wrote:
> >>
> >>> I get a compiler warning message at the following line of code:
> >>>
> >>> NSString *text = [NSString stringWithContentsOfFile:fullPath encoding:
> >>> NSUTF8StringEncoding error:&error];
> >>>
> >>> The warning message is:
> >>>
> >>> Class method '+stringWithContentsOfFile:encoding:Rf_error' not found
> >>> (return type defaults to 'id')
> >>>
> >>>
> >>> I've found many code examples that have the same as my code and nothing
> >>> I've tried gets rid of the warning message. Can someone please
> enlighten
> >> me?
> >>
> >> Check the headers. Is there anything that is #defining error to
> Rf_error?
> >>
> >> Nick Zitzmann
> >> 
> >
>
___

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

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

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

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


Re: Warning message using stringWithContentsOfFile:encoding:error:

2012-10-28 Thread Andy Lee
(Sorry again if the list gets this twice. I am going to strangle whoever 
thought it was a good idea to give me a me.com address as an alias for my 
mac.com address -- AND have Mail.app use one when I meant the other.)


On Oct 28, 2012, at 12:04 PM, Andy Lee  wrote:
> I Googled "Rf_error" and there is a code base out there with an Rf_error.c 
> file. Are you using that code base?

I Googled [define error rf_error] and found this file that #defines "error" as 
"Rf_error":



Any chance this file is in your project?

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Warning message using stringWithContentsOfFile:encoding:error:

2012-10-28 Thread Andy Lee
(Sorry if the list gets this twice. I am going to strangle whoever thought it 
was a good idea to give me a me.com address as an alias for my mac.com address.)


On Oct 27, 2012, at 6:04 PM, Paul Johnson  wrote:
> I get a compiler warning message at the following line of code:
> 
> NSString *text = [NSString stringWithContentsOfFile:fullPath encoding:
> NSUTF8StringEncoding error:&error];
> 
> The warning message is:
> 
> Class method '+stringWithContentsOfFile:encoding:Rf_error' not found
> (return type defaults to 'id')


Is this warning exactly what the compiler said, or did you manually copy it, 
possibly with a typo?

The reason I ask is that "stringWithContentsOfFile:encoding:Rf_error" is not a 
valid method name (it's missing a colon at the end). It seems odd that the 
compiler would think it was the message you were trying to send. If so, I 
wonder if there is a compiler bug.

I Googled "Rf_error" and there is a code base out there with an Rf_error.c 
file. Are you using that code base? I'm not sure how it could cause the problem 
-- I'm just wondering where the compiler could have come up with "Rf_error".

On Oct 27, 2012, at 7:21 PM, Paul Johnson  wrote:
> The warning message seems to be complaining about assigning to the type
> 'NString *' when type 'id' is expected, though.

No. You can freely assign any object pointer to id and vice versa. The warning 
says "method ... not found", and that's exactly what it means. The compiler is 
not aware of NSString (or any of its superclasses or protocols) having a method 
with that name, where for some reason "that name" is a screwy name rather than 
the one you intended.

On Oct 27, 2012, at 8:41 PM, Gary L. Wade  wrote:
> What you need to find is where "error" is being defined, not Rf_error.

This might help: type "error" right after the closing semicolon of the 
statement you showed us. Then Command-click on it and see where Xcode takes you.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: variable problem is driving me nuts

2012-10-28 Thread Mike Abdullah

On 28 Oct 2012, at 01:18, M Pulis  wrote:

> clients is not (yet) a proper NSMutableArray..
> 
> Try one of the init methods within the NSMutableArray.

I'm sorry? -init is a perfectly reasonable method to call here.

___

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

Please do not post 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


Re: variable problem is driving me nuts

2012-10-28 Thread Roland King

On 28 Oct, 2012, at 8:01 PM, H Miersch  wrote:

> then why does Xcode complain about an unused result? this is just another 
> example of a TOTALLY USELESS error message. 
> 
> anyway, i fixed it, and now it works. thanks.
> 
> On 28. Oct 2012, at 11:56, Roland King  wrote:
> 
>> 
>> On 28 Oct, 2012, at 7:50 PM, H Miersch  wrote:
>> 
>>> ok, it looks like i've sorted the original problem. but here's the next one:
>>> 
>>> i have this line:
>>> 
>>> for (i = 0; i++; i < count) {…}
>>> 
>>> in the app delegate. Xcode keeps giving me this warning: expression result 
>>> unused. WTF? that is correct syntax for a for loop, isn't it? so then why 
>>> do i keep getting this warning?
>>> also, i have confirmed that the statements between { and } are NOT 
>>> executed, no matter what. that's not right either. so WTF is going on here?
>>> ___
>> 
>> 
>> no it's not even vaguely the right syntax for a for loop. You have 
>> 
>>  for( initialiser, iterator, condition )
>> 
>> it's supposed to be 
>> 
>>  for( initialiser, condition, iterator )
>> 
>> that's just basic C
>> 
>> so change it to 
>> 
>>  for( i = 0 ; i < count ; i++)
>> 
>> Xcode is totally correct here. 
> 

because you are not using the result of i < count which was a hint that you had 
made a mistake. So no that is not another TOTALLY USELESS error message, it's 
actually a pretty good error message from the compiler which has no idea what 
you've done but knows you have evaluated something and then not used the 
answer. In the end it got you to ask the question "that is correct syntax for a 
loop isn't it?" and it wasn't so I think you might cut the compiler a bit of 
slack here. 
___

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

Please do not post 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

Re: variable problem is driving me nuts

2012-10-28 Thread Antonio Nunes
On 28 Oct, 2012, at 12:50 , H Miersch  wrote:

> ok, it looks like i've sorted the original problem. but here's the next one:
> 
> i have this line:
> 
> for (i = 0; i++; i < count) {…}
> 
> in the app delegate. Xcode keeps giving me this warning: expression result 
> unused. WTF? that is correct syntax for a for loop, isn't it? so then why do 
> i keep getting this warning?
> also, i have confirmed that the statements between { and } are NOT executed, 
> no matter what. that's not right either. so WTF is going on here?

for (i=0;ihttps://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: variable problem is driving me nuts

2012-10-28 Thread H Miersch
then why does Xcode complain about an unused result? this is just another 
example of a TOTALLY USELESS error message. 

anyway, i fixed it, and now it works. thanks.

On 28. Oct 2012, at 11:56, Roland King  wrote:

> 
> On 28 Oct, 2012, at 7:50 PM, H Miersch  wrote:
> 
>> ok, it looks like i've sorted the original problem. but here's the next one:
>> 
>> i have this line:
>> 
>> for (i = 0; i++; i < count) {…}
>> 
>> in the app delegate. Xcode keeps giving me this warning: expression result 
>> unused. WTF? that is correct syntax for a for loop, isn't it? so then why do 
>> i keep getting this warning?
>> also, i have confirmed that the statements between { and } are NOT executed, 
>> no matter what. that's not right either. so WTF is going on here?
>> ___
> 
> 
> no it's not even vaguely the right syntax for a for loop. You have 
> 
>   for( initialiser, iterator, condition )
> 
> it's supposed to be 
> 
>   for( initialiser, condition, iterator )
> 
> that's just basic C
> 
> so change it to 
> 
>   for( i = 0 ; i < count ; i++)
> 
> Xcode is totally correct here. 


___

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

Please do not post 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

Re: variable problem is driving me nuts

2012-10-28 Thread Koen van der Drift

On Oct 28, 2012, at 7:50 AM, H Miersch  wrote:

> for (i = 0; i++; i < count) {…}

That should be for (i=0; i < count; i++) {}  ;-)

- Koen.
___

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

Please do not post 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

Re: variable problem is driving me nuts

2012-10-28 Thread Roland King

On 28 Oct, 2012, at 7:50 PM, H Miersch  wrote:

> ok, it looks like i've sorted the original problem. but here's the next one:
> 
> i have this line:
> 
> for (i = 0; i++; i < count) {…}
> 
> in the app delegate. Xcode keeps giving me this warning: expression result 
> unused. WTF? that is correct syntax for a for loop, isn't it? so then why do 
> i keep getting this warning?
> also, i have confirmed that the statements between { and } are NOT executed, 
> no matter what. that's not right either. so WTF is going on here?
> ___


no it's not even vaguely the right syntax for a for loop. You have 

for( initialiser, iterator, condition )

it's supposed to be 

for( initialiser, condition, iterator )

that's just basic C

so change it to 

for( i = 0 ; i < count ; i++)

Xcode is totally correct here. 
___

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

Please do not post 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

Re: variable problem is driving me nuts

2012-10-28 Thread H Miersch
ok, it looks like i've sorted the original problem. but here's the next one:

i have this line:

for (i = 0; i++; i < count) {…}

in the app delegate. Xcode keeps giving me this warning: expression result 
unused. WTF? that is correct syntax for a for loop, isn't it? so then why do i 
keep getting this warning?
also, i have confirmed that the statements between { and } are NOT executed, no 
matter what. that's not right either. so WTF is going on here?
___

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

Please do not post 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

Re: Binding alignment property of NSTextField

2012-10-28 Thread Luc Van Bogaert
I have confirmed that the viewcontroller property is set correctly. While 
trying to find out why the textfield alignment isn't updated accordingly 
through the binding, I have found that when I set the textfield's stringValue 
(eg. to the same string), the alignment does get updated to its correct 
setting. But setting the stringValue of the textfield seems way too costly for 
what I'm trying to achieve.

So, I tried to send the textfield setNeedsDisplay: and setNeedsLayout: messages 
when the alignment property changes, but that doesn't update the alignment of 
the textfield. 

On 27 Oct 2012, at 16:06, Luc Van Bogaert  wrote:

> Yes, I'm using a synthesised setter to change the property value. I am also 
> observing the property (to redraw the controller's view whenever something 
> changes) and this way I can confirm that the property is indeed changed in a 
> KVO compliant manner.
> 
> One thing I forgot to mention is that I'm using a NSValueTransformer with the 
> binding to translate the enum property values to the proper alignment setting 
> for the textfield. 
> 
> 
> On 27 Oct 2012, at 11:58, Ken Thomases  wrote:
> 
>> On Oct 27, 2012, at 4:26 AM, Luc Van Bogaert wrote:
>> 
>>> The textfield alignment is bound to an enum property of the viewcontroller. 
>>> The strange thing is that, when I create a *new* viewcontroller object from 
>>> the nib, the textfield alignment is set correctly based on the current enum 
>>> property value. So, it seems that the binding indeed works, but
>>> 
>>> when I set the enum property of an existing viewcontroller object to some 
>>> other value, the textfield alignment is not adjusted accordingly.
>> 
>> This suggests that your are modifying the property in a non-KVO-compliant 
>> manner.  Are you calling the setter or are you directly changing the 
>> instance variable?
>> 
>> Regards,
>> Ken
>> 
> 
> -- 
> Luc Van Bogaert
> luc.van.boga...@me.com
> http://www.rixhon.be
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/luc.van.bogaert%40me.com
> 
> This email sent to luc.van.boga...@me.com

-- 
Luc Van Bogaert
luc.van.boga...@me.com
http://www.rixhon.be



___

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

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

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

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


Re: variable problem is driving me nuts

2012-10-28 Thread Kyle Sluder
On Oct 27, 2012, at 6:02 PM, Jens Alfke  wrote:

> In general, initialization code like this in a nib-loaded object should go 
> into its -awakeFromNib method, which is [almost] guaranteed to be the first 
> method invoked on that object.

Actually, the NSTableView docs explicitly warn that this is not the case:

> Important: It is possible that your datasource methods for populating the 
> table view may be called before awakeFromNib is called if the datasource is 
> specified in Interface Builder. You should defend against this by having the 
> datasource’s numberOfRowsInTableView: method return 0 for the number of rows 
> when the datasource has not yet been configured. In awakeFromNib, when the 
> datasource is initialized you should always call reloadData on the table view.

Initialize your instance variable in -init, which *is* guaranteed to be the 
first method called on your object.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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