diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e555c0f --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# Xcode +.DS_Store +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +*.xcworkspace +!default.xcworkspace +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ + diff --git a/QRCodeGen.xcodeproj/project.pbxproj b/QRCodeGen.xcodeproj/project.pbxproj index a30a8de..66e6221 100644 --- a/QRCodeGen.xcodeproj/project.pbxproj +++ b/QRCodeGen.xcodeproj/project.pbxproj @@ -156,7 +156,9 @@ C0BB55691AEE8C850084259C /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastSwiftMigration = 0710; + LastSwiftUpdateCheck = 0710; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = Appcoda; TargetAttributes = { C0BB55701AEE8C850084259C = { @@ -276,6 +278,7 @@ COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -342,6 +345,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = QRCodeGen/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.appcoda.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -352,6 +356,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = QRCodeGen/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.appcoda.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -370,6 +375,7 @@ ); INFOPLIST_FILE = QRCodeGenTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.appcoda.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QRCodeGen.app/QRCodeGen"; }; @@ -385,6 +391,7 @@ ); INFOPLIST_FILE = QRCodeGenTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "com.appcoda.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/QRCodeGen.app/QRCodeGen"; }; @@ -409,6 +416,7 @@ C0BB55921AEE8C850084259C /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; C0BB55931AEE8C850084259C /* Build configuration list for PBXNativeTarget "QRCodeGenTests" */ = { isa = XCConfigurationList; @@ -417,6 +425,7 @@ C0BB55951AEE8C850084259C /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/QRCodeGen.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/QRCodeGen.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index d1b4fd8..0000000 --- a/QRCodeGen.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/QRCodeGen.xcodeproj/xcuserdata/gabriel.xcuserdatad/xcschemes/QRCodeGen.xcscheme b/QRCodeGen.xcodeproj/xcuserdata/gabriel.xcuserdatad/xcschemes/QRCodeGen.xcscheme deleted file mode 100644 index 94abe6f..0000000 --- a/QRCodeGen.xcodeproj/xcuserdata/gabriel.xcuserdatad/xcschemes/QRCodeGen.xcscheme +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/QRCodeGen.xcodeproj/xcuserdata/gabriel.xcuserdatad/xcschemes/xcschememanagement.plist b/QRCodeGen.xcodeproj/xcuserdata/gabriel.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index eceabd7..0000000 --- a/QRCodeGen.xcodeproj/xcuserdata/gabriel.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - SchemeUserState - - QRCodeGen.xcscheme - - orderHint - 0 - - - SuppressBuildableAutocreation - - C0BB55701AEE8C850084259C - - primary - - - C0BB55851AEE8C850084259C - - primary - - - - - diff --git a/QRCodeGen.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/QRCodeGen.xcscheme b/QRCodeGen.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/QRCodeGen.xcscheme deleted file mode 100644 index 94abe6f..0000000 --- a/QRCodeGen.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/QRCodeGen.xcscheme +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/QRCodeGen.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/xcschememanagement.plist b/QRCodeGen.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index eceabd7..0000000 --- a/QRCodeGen.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - SchemeUserState - - QRCodeGen.xcscheme - - orderHint - 0 - - - SuppressBuildableAutocreation - - C0BB55701AEE8C850084259C - - primary - - - C0BB55851AEE8C850084259C - - primary - - - - - diff --git a/QRCodeGen/Info.plist b/QRCodeGen/Info.plist index bf4ff2e..6905cc6 100644 --- a/QRCodeGen/Info.plist +++ b/QRCodeGen/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.appcoda.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/QRCodeGen/ViewController.swift b/QRCodeGen/ViewController.swift index ca68330..b560246 100644 --- a/QRCodeGen/ViewController.swift +++ b/QRCodeGen/ViewController.swift @@ -41,20 +41,20 @@ class ViewController: UIViewController { return } - let data = textField.text.dataUsingEncoding(NSISOLatin1StringEncoding, allowLossyConversion: false) + let data = textField.text!.dataUsingEncoding(NSISOLatin1StringEncoding, allowLossyConversion: false) - let filter = CIFilter(name: "CIQRCodeGenerator") - - filter.setValue(data, forKey: "inputMessage") - filter.setValue("Q", forKey: "inputCorrectionLevel") - - qrcodeImage = filter.outputImage - - textField.resignFirstResponder() - - btnAction.setTitle("Clear", forState: UIControlState.Normal) - - displayQRCodeImage() + if let filter = CIFilter(name: "CIQRCodeGenerator") { + filter.setValue(data, forKey: "inputMessage") + filter.setValue("Q", forKey: "inputCorrectionLevel") + + qrcodeImage = filter.outputImage + + textField.resignFirstResponder() + + btnAction.setTitle("Clear", forState: UIControlState.Normal) + + displayQRCodeImage() + } } else { imgQRCode.image = nil @@ -75,8 +75,8 @@ class ViewController: UIViewController { // MARK: Custom method implementation func displayQRCodeImage() { - let scaleX = imgQRCode.frame.size.width / qrcodeImage.extent().size.width - let scaleY = imgQRCode.frame.size.height / qrcodeImage.extent().size.height + let scaleX = imgQRCode.frame.size.width / qrcodeImage.extent.size.width + let scaleY = imgQRCode.frame.size.height / qrcodeImage.extent.size.height let transformedImage = qrcodeImage.imageByApplyingTransform(CGAffineTransformMakeScale(scaleX, scaleY)) diff --git a/QRCodeGenTests/Info.plist b/QRCodeGenTests/Info.plist index ebe929c..ba72822 100644 --- a/QRCodeGenTests/Info.plist +++ b/QRCodeGenTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - com.appcoda.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName