0

I'm having a trouble with override init() {} method which is running in loop. Until it crash with exc_bad_access.

override init() {
    super.init()
    self.container = UIView()
    self.container.clipsToBounds = false

    println("self.container: \(self.container)")
    self.addSubview(self.container)

    self.contentCenter = CGPointZero
    self.contentScale = 1
    refreshContentTransform()

    self.panRecognizer = UIPanGestureRecognizer(target: self, action: Selector("handlePan:"))
    self.panRecognizer.maximumNumberOfTouches = 1
    self.panRecognizer.minimumNumberOfTouches = 1
    self.addGestureRecognizer(self.panRecognizer)

    self.pinchRecognizer = UIPinchGestureRecognizer(target: self, action: Selector("handlePinch:"))
    self.addGestureRecognizer(self.pinchRecognizer)
}

what could be the trigger?

Before this class init was called. I have a var of that class initialize via var item = MyVar() tracking with break point. it never goes out of that init and somehow continues to loop. :/ I hope someone could give me some advice. thanks.

eNeF
  • 3,241
  • 2
  • 18
  • 41
  • It looks like part of your question ended up inside your code block, and reading your question, it isn't really clear what you're asking. You should take a look at this again and see if you can clarify yourself a bit. – Sam Hanley Aug 29 '14 at 14:49
  • I updated my post. Its just like that.. This is supposed to be like self = [super init]; if (self) {//code here } return self; but in swift self it is readonly. So I'm having trouble achieving the same output. Thanks for the reply btw. – eNeF Sep 01 '14 at 01:15
  • Nothing's wrong with the code you posted. Can you show the loop you're talking about? – Aaron Brager Sep 01 '14 at 02:20
  • What does `refreshContentTransform()` do? – Aaron Brager Sep 01 '14 at 02:22
  • func refreshContentTransform() { var transform: CGAffineTransform = CGAffineTransformIdentity transform = CGAffineTransformTranslate(transform, self.contentCenter.x, self.contentCenter.y) transform = CGAffineTransformScale(transform, self.contentScale, self.contentScale); self.container.transform = transform println("transform \(transform)") } ..my mistake. This was solve and that code above was already altered. I think I have called its class name inside init instead of self. now I'm having trouble with initializing a self from nib file. – eNeF Sep 01 '14 at 05:55

0 Answers0