[MacRuby-devel] My class's initialize not called
steve ross
cwdinfo at gmail.com
Thu Jan 21 15:20:20 PST 2010
I'm sure this is an elementary question, but I have the class below. In IB, I set several NSTextField controls to this class. Everything works in the blah, blah, blah part, but strangely enough the
puts "initialize dctf"
never seems to be called. Any thoughts as to why?
require 'strings'
class DuplicateCounterTextField < NSTextField
include Strings
attr_accessor :splitter, :completions
attr_accessor :wordCount, :duplicateCount
def initialize
puts "initialize dctf"
@splitter = /\W+/
@wordCount = 0
@cachedWordCount = 0
@duplicateCount = 0
end
# blah, blah, blah working code
def textDidChange(notification)
words = stringValue.split(@splitter)
@wordCount = words.length
@duplicateCount = @wordCount - words.uniq.length
if delegate.respond_to?('controlCountDidChange:wordCount:duplicateCount:')
delegate.controlCountDidChange(self,
wordCount:@wordCount,
duplicateCount:@duplicateCount)
end
end
# etc.
end
More information about the MacRuby-devel
mailing list