Hi, I'm having trouble calling the Foundation function NSLocalizedString from within a method I have added to class NSRunningApplication: class NSRunningApplication def activeString active? ? NSLocalizedString("Yes", "Yes") : NSLocalizedString("No", "No") end end The error message I get is: undefined method `NSLocalizedString' for #<NSKVONotifying_NSRunningApplication:0x40127e680> (NoMethodError) I can however successfully call NSLog, which is another Foundation function, from the same place. Is there a way I can call NSLocalizedString (and why is NSLog a special case)? Thanks for any info. -- Colin
Hi Colin, You have issues because NSLocalizedString isn't a C function, I'm not sure, but I believe that it is preprocessor macros because it Xcode it highlight's as a macros: http://cl.ly/Bqw9 On Wed, Nov 16, 2011 at 7:39 PM, Colin McPhail <mcphail_colin@hotmail.com>wrote:
Hi,
I'm having trouble calling the Foundation function NSLocalizedString from within a method I have added to class NSRunningApplication:
class NSRunningApplication def activeString active? ? NSLocalizedString("Yes", "Yes") : NSLocalizedString("No", "No") end end
The error message I get is: undefined method `NSLocalizedString' for #<NSKVONotifying_NSRunningApplication:0x40127e680> (NoMethodError)
I can however successfully call NSLog, which is another Foundation function, from the same place.
Is there a way I can call NSLocalizedString (and why is NSLog a special case)?
Thanks for any info. -- Colin _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Igor, You are right, NSLocalizedString is a macro. I never thought of that! Thank you. -- Colin On 16 Nov 2011, at 18:14, Игорь Владимирович Евсюков wrote:
Hi Colin,
You have issues because NSLocalizedString isn't a C function, I'm not sure, but I believe that it is preprocessor macros because it Xcode it highlight's as a macros: http://cl.ly/Bqw9
On Wed, Nov 16, 2011 at 7:39 PM, Colin McPhail <mcphail_colin@hotmail.com> wrote: Hi,
I'm having trouble calling the Foundation function NSLocalizedString from within a method I have added to class NSRunningApplication:
class NSRunningApplication def activeString active? ? NSLocalizedString("Yes", "Yes") : NSLocalizedString("No", "No") end end
The error message I get is: undefined method `NSLocalizedString' for #<NSKVONotifying_NSRunningApplication:0x40127e680> (NoMethodError)
I can however successfully call NSLog, which is another Foundation function, from the same place.
Is there a way I can call NSLocalizedString (and why is NSLog a special case)?
Thanks for any info. -- Colin _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
It’s a macro and I solved this problem like this: module Kernel private def NSLocalizedString(key, value) NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil) end end this question has already been here: http://lists.macosforge.org/pipermail/macruby-devel/2011-February/007196.htm... I hope I could help you! On Wednesday, November 16, 2011 6:39:03 PM UTC+1, CMcP wrote:
Hi,
I'm having trouble calling the Foundation function NSLocalizedString from within a method I have added to class NSRunningApplication:
class NSRunningApplication def activeString active? ? NSLocalizedString("Yes", "Yes") : NSLocalizedString("No", "No") end end
The error message I get is: undefined method `NSLocalizedString' for #<NSKVONotifying_NSRunningApplication:0x40127e680> (NoMethodError)
I can however successfully call NSLog, which is another Foundation function, from the same place.
Is there a way I can call NSLocalizedString (and why is NSLog a special case)?
Thanks for any info. -- Colin _______________________________________________ MacRuby-devel mailing list MacRub...@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Thank you! I promise to do a better search before I ask any more questions. On 16 Nov 2011, at 19:25, Mateus Armando wrote:
It’s a macro and I solved this problem like this:
module Kernel private
def NSLocalizedString(key, value) NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil) end end
this question has already been here: http://lists.macosforge.org/pipermail/macruby-devel/2011-February/007196.htm... I hope I could help you!
On Wednesday, November 16, 2011 6:39:03 PM UTC+1, CMcP wrote: Hi, I'm having trouble calling the Foundation function NSLocalizedString from within a method I have added to class NSRunningApplication:
class NSRunningApplication def activeString active? ? NSLocalizedString("Yes", "Yes") : NSLocalizedString("No", "No") end end
The error message I get is: undefined method `NSLocalizedString' for #<NSKVONotifying_NSRunningApplication:0x40127e680> (NoMethodError)
I can however successfully call NSLog, which is another Foundation function, from the same place.
Is there a way I can call NSLocalizedString (and why is NSLog a special case)?
Thanks for any info. -- Colin _______________________________________________ MacRuby-devel mailing list MacRub...@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Colin McPhail
-
Mateus Armando
-
Игорь Владимирович Евсюков