I’m trying to get all the content of a scroll view as list, but i have the error :
“-[NSScrollView stringValue]: unrecognized selector sent to instance 0x200a5dd60”
I connect the property Field_Dossier to the scrollview.
Here is the code :
script textfieldAppDelegate
property parent : class "NSObject"
-- IBoutlet -----------------------------------------
property Field_Dossier : missing value
-- IBaction -----------------------------------------
on monbouton_(sender)
set List_Dossier to Field_Dossier's stringValue() as text
display dialog List_Dossier
end monbouton_
-- Application -----------------------------------------
on applicationWillFinishLaunching_(aNotification)
end applicationWillFinishLaunching_
on applicationShouldTerminate_()
-- Insert code here to do any housekeeping before your application quits
return my NSTerminateNow
end applicationShouldTerminate_
end script
you probably mean a text view, the parent scroll view doesn’t contain text.
Connect the variable Field_Dossier to the NSTextView instance at the top of the text area in the scroll view.
Then use this code
set List_Dossier to Field_Dossier's textStorage's |string|() as text
But now, i want to do the opposite but it doesn’t work.
i wrote my text in my pref and when the app open, i want to put that text in my scroll view
here is my code :
tell NSUserDefaults
tell its standardUserDefaults()
set LectureTextePref to its objectForKey_("MesDossiers") -- the text i want
end tell
end tell
display dialog LectureTextePref as string -- which is working
Field_Dossier's setTextStorage_(LectureTextePref)
the error return : “-[NSTextView setTextStorage:]: unrecognized selector sent to instance 0x2006d78a0”
that’s not the opposite. NSTextStorage is a semiconcrete subclass of NSMutableAttributedString, not a property
tell NSUserDefaults
tell its standardUserDefaults()
set LectureTextePref to its stringForKey_("MesDossiers") -- the text i want
end tell
end tell
set textToInsert to current application's NSAttributedString's alloc's initWithString_(LectureTextePref)
Field_Dossier's textStorage's setAttributedString_(textToInsert)
textToInsert's release
And as a general suggestion Chrismacteam, try to always write your variables in the same way that the methods are written, i.e. lowercase first then each new word begins with an uppercase (like this: aNewString, not like this: ANewString or Anewstring). This way you will have a homogenous writing system and will prevent problems down the road.
To give you an example, lately I brought some old ASS code to my new ASOC app, and it took me 2 days to find the problem, but somewhere I needed to get the window’s frame like this mainWindow’s frame(), but it got changed somehow by Xcode to Frame() and it stopped working. Even if I had put frame between || it changed back to Frame without the brackets. Somewhere in my old code I had variables that were written like I used to a while back (like FrameColor) and this was the source of the problem.
It’s not a written rule, but it helps with Xcode and ASOC, in my experience.
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)