Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import StoreKit
- class QRCodeGenerator: UIViewController {
- var product_id: NSString?;
- @IBOutlet weak var userText: UITextView!
- @IBOutlet weak var infoLabel: UILabel!
- var qrString : String?
- var segue = true
- var codeCount = 0
- override func viewDidLoad() {
- product_id = "FullAccess"
- super.viewDidLoad()
- self.navigationItem.title = "QR Code Generator"
- self.userText.text = self.qrString
- }
- override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) {
- if segue!.identifier == "QR" {
- if self.userText.text != ""{
- let ImageviewController : QRImage = segue!.destinationViewController as QRImage
- ImageviewController.userTextString = self.userText.text
- }
- }
- }
- override func shouldPerformSegueWithIdentifier(identifier: String?, sender: AnyObject?) -> Bool {
- if identifier == "QR"{
- if (userText.text.isEmpty) {
- let alert = UIAlertView()
- alert.title = "No Text"
- alert.message = "Please Enter Text In The Box"
- alert.addButtonWithTitle("Ok")
- alert.show()
- return false
- }
- else {
- return true
- }
- }
- // by default, transition
- return true
- }
- override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
- self.view.endEditing(true)
- }
- @IBAction func showMeQRCodeAction(sender: AnyObject) {
- if self.segue{
- let fileManger = NSFileManager.defaultManager()
- var error : NSError?
- var doumentDirectoryPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
- let destinationPath = doumentDirectoryPath.stringByAppendingPathComponent("QRGenerator.plist")
- var data : NSMutableDictionary?
- data = NSMutableDictionary(contentsOfFile: destinationPath)
- var QRCount : Int = data?.objectForKey("QRCount") as Int
- QRCount++
- self.codeCount = QRCount
- if QRCount > 10{
- println("Called")
- }
- data?.setObject(QRCount, forKey: "QRCount")
- data?.writeToFile(destinationPath, atomically: true)
- println(data!)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment