RubyMotion을 처음 사용하고 개체 초기화 작업 방법을 이해하려고합니다. 다음 작업 않는 이유를 이제RubyMotion에서 개체 초기화
class Something
def self.getSomething
BubbleWrap::HTTP.post("http://example.com") do |response|
p response
end
end
def getSomething
BubbleWrap::HTTP.post("http://example.com") do |response|
p response
end
end
end
, : 하나 개의 클래스와 인스턴스 방법과 간단한 클래스를 가정하지
Something.getSomething
그리고 다음 조각을 잘, 때때로 (이 조각과 런타임을 실행 10 회 중 8 회 충돌).
something = Something.new
something.getSomething
내가 잘못하고있다. 올바른 방향의 포인터?
메소드 중 하나가'self.getSomething'으로되어 있습니까? –
@DylanMarkow 오른쪽, 오타. 고쳤다. – Cimm
이것은 RubyMotion의 로컬 변수 처리가 중요하지 않은 것과 관련이 있습니다. 대신 인스턴스 변수를 사용하면 어떻게됩니까? '@something = Something.new; @ something.getSomething' –