0

This is a weird and frustrating problem because these codes work on my friends computer and iPhone device when i asked him to test it, but it does not work on my computer and iPhone 4. The error is called "Thread 1: EXC_BAD_ACCESS(code=1,address=0x10)" and it occurs on the var alert declaration. This occurs after i click the button on my iPhone device during testing.

@IBAction func button(sender: AnyObject) {

    self.showRateMe()

}


//MARK: - Private Methods
func showRateMe()
{


var alert = UIAlertController(title: "Rate Us", message: "Thanks for
using the app! We value your feedback. Please take a few seconds to
review our app to make it better", preferredStyle:
UIAlertControllerStyle.Alert)


    alert.addAction(UIAlertAction(title: "Hello!", style: UIAlertActionStyle.Default, handler:
        { alertAction in
            self.openReviewPage()
            alert.dismissViewControllerAnimated(true, completion: nil)
    }))
    alert.addAction(UIAlertAction(title: "No Thanks", style: UIAlertActionStyle.Default, handler: { alertAction in

        alert.dismissViewControllerAnimated(true, completion: nil)
    }))


    /*
    alert.addAction(UIAlertAction(title: "Maybe Later", style: UIAlertActionStyle.Default, handler: { alertAction in
    alert.dismissViewControllerAnimated(true, completion: nil)
    }))
    */

    self.presentViewController(alert, animated: true, completion: nil)

}
Spotlight
  • 472
  • 1
  • 11
  • 22
oscar
  • 11
  • 2

1 Answers1

0

I believe your problem is that you have 2 hard returns in your alert message and the compiler is not amused. I cut and pasted your code, removed the hard returns, and it works as expected. Cheers.

miken32
  • 42,008
  • 16
  • 111
  • 154
NoClue
  • 211
  • 4
  • 13
  • it has hard returns on this question because a smartass edited it and downvoted me. but the codes in my xCode does not have any hard returns and it is still not working properly. i feel like after downloading this new xCode beta it messed up my version 6.4 How can i fix this? it works on yours and on my friend's iPhone device testing! – oscar Aug 15 '15 at 05:09
  • can you please tell me exactly what you did after copying and pasting the code to your xcode? how exactly did you remove the hard returns that you mentioned? i uninstalled xCode including all the files connected to it and installed it again. its still have the same issue. please help youre my last hope – oscar Aug 15 '15 at 07:18
  • All I did was remove the hard returns (before review and using), then added in a blank function for openReviewPage(), but it sounds like that wasn't your issue, if the returns were edited in. I noticed that the compiler still showed issues (falsely), but it builds successfully if you force a build, at least on my end. Have you checked all of your outlets? The compiler is telling you it's trying to access something in memory that isn't there. Have you deleted/changed anything on the canvas without removing the connections? I'm also on 6.4 btw – NoClue Aug 15 '15 at 11:57
  • 1
    OK i fixed the problem now FINALLY!! the problem is i was using UIAlertController which ONLY works for iOs 8+ but my target deployment is 7.0+ so i had to use the old UIAlertView instead and i had to change the entire code to fit that class. – oscar Aug 15 '15 at 19:18