delegate with (NSString **) argument?

Coding Questions, IDE related or anything else

delegate with (NSString **) argument?

Postby udo.killermann » Sat Jul 31, 2010 12:41 pm

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
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: delegate with (NSString **) argument?

Postby berndnoetscher » Tue Aug 03, 2010 9:36 am

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 **.
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Re: delegate with (NSString **) argument?

Postby udo.killermann » Tue Aug 03, 2010 8:37 pm

Bernd,

this leads to the following error:
internalError.jpg
internalError.jpg (48.76 KiB) Viewed 2913 times


But the executable is bound.

Regards
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: delegate with (NSString **) argument?

Postby berndnoetscher » Wed Aug 04, 2010 7:30 pm

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

berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Re: delegate with (NSString **) argument?

Postby udo.killermann » Sun Sep 12, 2010 5:52 pm

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.
textService.zip
(79.87 KiB) Downloaded 193 times


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
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: delegate with (NSString **) argument?

Postby berndnoetscher » Mon Sep 13, 2010 12:12 pm

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.
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Re: delegate with (NSString **) argument?

Postby udo.killermann » Mon Sep 13, 2010 8:35 pm

Bernd,

take the time you need - no hurry needed.

Regards
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: delegate with (NSString **) argument?

Postby berndnoetscher » Mon Nov 08, 2010 1:01 pm

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
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am


Return to Objective-Basic (Xcode 3)

Who is online

Users browsing this forum: No registered users and 1 guest

cron