delegate with (NSString **) argument?
Posted:
Sat Jul 31, 2010 12:41 pm
by udo.killermann
Bernd,
is it possible to define a delegate with this signature?
- Code: Select all
Declare Delegate "UKTextService" - (void)callOBFromTextService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error
I found no way to express (NSString **) in an As clause.
Regards
Udo
Re: delegate with (NSString **) argument?
Posted:
Tue Aug 03, 2010 9:36 am
by berndnoetscher
udo.killermann wrote:Bernd,
is it possible to define a delegate with this signature?
- Code: Select all
Declare Delegate "UKTextService" - (void)callOBFromTextService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error
I found no way to express (NSString **) in an As clause.
Regards
Udo
Didn't have time to test it, but as I remember it works. Just use the declare statement with NSString **, but the objb function declaration with As NSString. It will be internally used as **.
Re: delegate with (NSString **) argument?
Posted:
Tue Aug 03, 2010 8:37 pm
by udo.killermann
Bernd,
this leads to the following error:
- internalError.jpg (48.76 KiB) Viewed 2909 times
But the executable is bound.
Regards
Udo
Re: delegate with (NSString **) argument?
Posted:
Wed Aug 04, 2010 7:30 pm
by berndnoetscher
udo.killermann wrote:Bernd,
this leads to the following error:
internalError.jpg
But the executable is bound.
Regards
Udo
How bad. At least the following example uses declare functions with pointers and it works.
- Code: Select all
' The following event sub is automatically called when your app starts.
' Why? The global.NSObject is part of the MainMenu.nib file, which
' is automatically loaded and created during start up. After that its event sub AwakeFromNib() is executed.
Declare Function "NSString" + (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error
Declare Function "NSString" + (id) alloc
Declare Function "NSString" - (id)initWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error
Event AwakeFromNib()
Dim enc As id = 0
Dim err As id = Nil ' the parameter, which must be past byref (NSError **) must be a local variable, otherwise you will get a compiler error
Dim s As NSString = NSString.stringWithContentsOfFile("/Users/berndnoetscher/Desktop/test.txt2", encoding:=enc, error:=err)
''Alert(s)
Alert(Info(err))
Dim s As NSString = NSString.alloc()
s = s.initWithContentsOfFile("/Users/berndnoetscher/Desktop/test.txt2", encoding:=enc, error:=err)
'' Alert(s)
Alert(Info(err))
End Event
The following objb code looks like it compiles to valid objc code.
- Code: Select all
Declare Delegate "UKTextService" - (void)callOBFromTextService:(id)pboard userData:(NSString *)userData error:(NSString **)error
Delegate callOBFromTextService(aTableView As id, userData As NSString, error As NSString)
Alert("test", error)
End Delegate
Re: delegate with (NSString **) argument?
Posted:
Sun Sep 12, 2010 5:52 pm
by udo.killermann
Bernd,
even the current compiler throws above error with the delegate. This happens for my original code and for your code as well.
I attach the project for you to see.
In the error log the following is written:
- Code: Select all
12.09.10 18:47:26 textService[4388] Cannot find service provider for selector callOBFromTextService:userData:error: or callOBFromTextService:: for service callOBFromTextService
Kind regards
Udo
Re: delegate with (NSString **) argument?
Posted:
Mon Sep 13, 2010 12:12 pm
by berndnoetscher
Udo,
will take a look the next week, I guess.
Sorry for the delay, but I am busy with Q7Basic, which needs some improvements first.
Re: delegate with (NSString **) argument?
Posted:
Mon Sep 13, 2010 8:35 pm
by udo.killermann
Bernd,
take the time you need - no hurry needed.
Regards
Udo
Re: delegate with (NSString **) argument?
Posted:
Mon Nov 08, 2010 1:01 pm
by berndnoetscher
udo.killermann wrote:Bernd,
take the time you need - no hurry needed.
Regards
Udo
Udo
there is a new keyword for pointer on arguments.
error AsRef NSString
- Code: Select all
Declare Delegate "UKTextService" - (void)callOBFromTextService:(id)pboard userData:(NSString *)userData error:(NSString **)error
Delegate callOBFromTextService(aTableView As id, userData As NSString, error AsRef NSString)
Alert("test", error)
End Delegate