Delegate doesn't compile

Coding Questions, IDE related or anything else

Delegate doesn't compile

Postby udo.killermann » Wed Dec 22, 2010 7:13 pm

Bernd,

please have a look:
Code: Select all
Declare Function "NSTextView" - (NSRange)selectedRange
Declare Sub "NSTextView" - (void)setSelectedRange:(NSRange)charRange
Declare Sub "NSTextView" - (void)complete:(id)sender
Declare Function "NSString" - (NSString *)substringWithRange:(NSRange)aRange
Declare Sub "NSTextView" - (void)startSpeaking:(id)sender

Declare Class "NSInteger"

Declare Delegate "NSTextView" - (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index

IBOutlet theTextfield As NSTextField
 
' the music plays within the Events of the TextView - while processing thesse we can
' use the instance decoration at hand to appropriatly react to the Event
Event TextViewDidChangeSelection(theTextView As NSTextView)
  Dim theRange As Range
  Dim theString As NSString
  Dim theSubString As NSString
  Dim theLocation As Integer
 
  theRange = theTextView.selectedRange()
'  Log(theRange.Length)
'  Log(theRange.Location)
'  Log(theRange)

' Length only has a nonzero value if the user actually selects something 
  If(theRange.Length) Then
    theString = theTextView.Value
    theSubString = theString.substringWithRange(theRange)
    theTextfield.StringValue=String(theSubString)
    If (Contains(theSubString, "Huhn")) Then
      ' Notification.startSpeaking(Nil)
     
     
      ' if you like to append after the selected text just comment the following line out
      theRange.Location = theRange.Location + theRange.Length
'      theLocation=theRange.Location
'      ' unselect range by setting its length to zero
      theRange.Length = 0
'     
      theTextView.setSelectedRange(theRange)
'      theTextView.Insert(" du bist ein ")
'     
'      theRange.Location=theLocation
'      theTextView.setSelectedRange(theRange)
       theTextView.complete(Nil)
'    Else
'      theTextfield.StringValue = ""
    End If 
 End If
 
 
End Event

Event TextDidEndEditing(Notification As id)
  Dim ra As Range
 

  Alert("End Editing",Notification)
End Event

'Event ShouldChangeText(ar As Array, Dummy As id)
'  Alert(ar)
'End Event

Event MouseDown(theEvent As NSEvent)
  Alert(theEvent) 
End Event

' if I use the KeyDown Event the character seems to be eleminated from the input buffer before
' the TextView actually sees it - it appears just as I have entered nothing i.e. pressed no key
' at all
Event KeyUp(theEvent As NSEvent)
  Log(theEvent.Characters())
End Event

Delegate textView(textView As NSTextView, words As Array, charRange As Range, index AsRef Integer) As NSArray
  Log(words)
  Return(Array("Katze","Maus"))
End Delegate

Event AwakeFromNib()
  Me.Delegate=Me 
End Event



The compiler states
Code: Select all
/Users/HU/Desktop/ObjectiveBasic/ukTextView/Build/Release/ObjC/UKTextView.mm: In function 'NSArray* -[UKTextView textView:completions:forPartialWordRange:indexOfSelectedItem:](UKTextView*, objc_selector*, NSTextView*, NSArray*, NSRange, NSInteger*)':
/Users/HU/Desktop/ObjectiveBasic/ukTextView/Build/Release/ObjC/UKTextView.mm:81: error: call of overloaded 'NSOBJECT(NSInteger*&)' is ambiguous
compilation terminated due to -Wfatal-errors.



When replacing AsRef with As the problem persists.

ukTextView.zip
the project
(231.79 KiB) Downloaded 137 times


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 doesn't compile

Postby udo.killermann » Thu Dec 23, 2010 10:35 am

if I replace (NSInteger *)index at the end of the delegate's signature with (NSInteger)index it works like it should - but I think this is quirky somehow.

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 doesn't compile

Postby berndnoetscher » Mon Jan 03, 2011 8:48 pm

udo.killermann wrote:if I replace (NSInteger *)index at the end of the delegate's signature with (NSInteger)index it works like it should - but I think this is quirky somehow.

Regards
Udo


Happy new year!

Udo,
Will be on vacation a few days, after that I will create a fix for this. please be patient.
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Re: Delegate doesn't compile

Postby udo.killermann » Wed Jan 05, 2011 7:19 am

Bernd,

happy new year for you as well. Enjoy your vacation - you deserve it.
I'll be patient and wait for your solution. I'll continue with the many features you have already implemented.

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


Return to Objective-Basic (Xcode 3)

Who is online

Users browsing this forum: No registered users and 1 guest

cron