Added extra check to prevent crashes on delete then load value

This commit is contained in:
matthewpalmer
2014-11-25 08:47:56 +11:00
parent 1339c47e0c
commit c6cb488af7
3 changed files with 24 additions and 15 deletions
+23 -14
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14A388b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6221" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6213"/>
</dependencies>
<scenes>
<!--View Controller-->
@@ -16,7 +16,7 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SK4-b0-x78">
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="SK4-b0-x78">
<rect key="frame" x="278" y="122" width="34" height="30"/>
<state key="normal" title="Save">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -25,16 +25,7 @@
<action selector="save:" destination="BYZ-38-t0r" eventType="touchUpInside" id="x0D-Hg-awu"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5KA-Tp-Vu9">
<rect key="frame" x="277" y="285" width="35" height="30"/>
<state key="normal" title="Load">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="loadData:" destination="BYZ-38-t0r" eventType="touchUpInside" id="atD-QV-TTn"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tpV-X6-FVb">
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tpV-X6-FVb">
<rect key="frame" x="272" y="456" width="44" height="30"/>
<state key="normal" title="Delete">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@@ -43,14 +34,32 @@
<action selector="deleteData:" destination="BYZ-38-t0r" eventType="touchUpInside" id="gee-TK-WNb"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gwg-uJ-dG8">
<rect key="frame" x="272" y="213" width="51" height="30"/>
<state key="normal" title="Update">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5KA-Tp-Vu9">
<rect key="frame" x="278" y="341" width="35" height="30"/>
<state key="normal" title="Load">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="loadData:" destination="BYZ-38-t0r" eventType="touchUpInside" id="atD-QV-TTn"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="tpV-X6-FVb" firstAttribute="centerX" secondItem="5KA-Tp-Vu9" secondAttribute="centerX" id="02U-GD-KNI"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="tpV-X6-FVb" secondAttribute="bottom" constant="114" id="0by-WH-3i4"/>
<constraint firstItem="SK4-b0-x78" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="102" id="BWt-zt-RaP"/>
<constraint firstItem="5KA-Tp-Vu9" firstAttribute="centerX" secondItem="gwg-uJ-dG8" secondAttribute="centerX" constant="-2" id="IbX-M1-W0g"/>
<constraint firstItem="5KA-Tp-Vu9" firstAttribute="top" secondItem="gwg-uJ-dG8" secondAttribute="bottom" constant="98" id="Yrl-i7-DvH"/>
<constraint firstItem="SK4-b0-x78" firstAttribute="centerX" secondItem="gwg-uJ-dG8" secondAttribute="centerX" constant="-2.5" id="bqc-O3-i05"/>
<constraint firstAttribute="centerX" secondItem="5KA-Tp-Vu9" secondAttribute="centerX" constant="5.5" id="e72-Mg-dNM"/>
<constraint firstItem="5KA-Tp-Vu9" firstAttribute="centerX" secondItem="SK4-b0-x78" secondAttribute="centerX" id="vz6-E2-ed9"/>
<constraint firstItem="gwg-uJ-dG8" firstAttribute="top" secondItem="SK4-b0-x78" secondAttribute="bottom" constant="61" id="pa1-N2-ahM"/>
<constraint firstItem="5KA-Tp-Vu9" firstAttribute="top" secondItem="SK4-b0-x78" secondAttribute="bottom" constant="133" id="xBP-DF-dFN"/>
</constraints>
</view>
+1 -1
View File
@@ -42,7 +42,7 @@ class Locksmith: NSObject {
if result != nil {
println("resultPointer \(result)")
if type == .Read {
if type == .Read && status == errSecSuccess {
if let data = result?.takeUnretainedValue() as? NSData {
// Convert the retrieved data to a dictionary
resultsDictionary = NSKeyedUnarchiver.unarchiveObjectWithData(data) as? NSDictionary