Skip to content

Commit

Permalink
Swift 3 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tallerthenyou committed May 26, 2017
1 parent 7494b17 commit dfe6085
Show file tree
Hide file tree
Showing 32 changed files with 734 additions and 632 deletions.
2 changes: 1 addition & 1 deletion IOStream/Arc4RandomStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ @implementation Arc4RandomStream
- (id)init {
uint8_t buffer[256];

SecRandomCopyBytes(kSecRandomDefault, sizeof(buffer), buffer);
(void) SecRandomCopyBytes(kSecRandomDefault, sizeof(buffer), buffer);

return [self init:[NSData dataWithBytes:buffer length:sizeof(buffer)]];
}
Expand Down
2 changes: 1 addition & 1 deletion KeePassLib/Salsa20RandomStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ @implementation Salsa20RandomStream
- (id)init {
uint8_t buffer[256];

SecRandomCopyBytes(kSecRandomDefault, sizeof(buffer), buffer);
(void) SecRandomCopyBytes(kSecRandomDefault, sizeof(buffer), buffer);

return [self init:[NSData dataWithBytes:buffer length:sizeof(buffer)]];
}
Expand Down
30 changes: 25 additions & 5 deletions MiniKeePass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
52491D0F14D8F3FB00F8CBC8 /* de-keyfiles.html in Resources */ = {isa = PBXBuildFile; fileRef = 52491D0A14D8F3FB00F8CBC8 /* de-keyfiles.html */; };
52491D1014D8F3FB00F8CBC8 /* de-safariemail.html in Resources */ = {isa = PBXBuildFile; fileRef = 52491D0B14D8F3FB00F8CBC8 /* de-safariemail.html */; };
526D9FAD167CDC2E0097213E /* libMBProgressHUD.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 526D9FAB167CDC010097213E /* libMBProgressHUD.a */; };
5271A98D1ED7CA3E00B9AF2C /* TextFieldCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5271A98C1ED7CA3E00B9AF2C /* TextFieldCell.xib */; };
529708B014FEF149003547FB /* Andale Mono.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 529708AD14FEEFD3003547FB /* Andale Mono.ttf */; };
52A177BC13EB698E00CEEFCE /* createdb.html in Resources */ = {isa = PBXBuildFile; fileRef = 52A177BB13EB698E00CEEFCE /* createdb.html */; };
52E43F4C15B59C890029F979 /* ru-createdb.html in Resources */ = {isa = PBXBuildFile; fileRef = 52E43F4715B59C880029F979 /* ru-createdb.html */; };
Expand Down Expand Up @@ -168,6 +169,7 @@
52491D0A14D8F3FB00F8CBC8 /* de-keyfiles.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "de-keyfiles.html"; sourceTree = "<group>"; };
52491D0B14D8F3FB00F8CBC8 /* de-safariemail.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "de-safariemail.html"; sourceTree = "<group>"; };
526D9FA3167CDC010097213E /* MBProgressHUD.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MBProgressHUD.xcodeproj; path = MBProgressHUD/MBProgressHUD.xcodeproj; sourceTree = "<group>"; };
5271A98C1ED7CA3E00B9AF2C /* TextFieldCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TextFieldCell.xib; sourceTree = "<group>"; };
529708AD14FEEFD3003547FB /* Andale Mono.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Andale Mono.ttf"; sourceTree = "<group>"; };
529BED9E14D7CD8600618250 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
529BED9F14D7CD9700618250 /* de */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -845,12 +847,13 @@
689FBE831AB27283005CB6BD /* PasswordFieldCell.m */,
689FBE861AB27283005CB6BD /* TextFieldCell.h */,
689FBE871AB27283005CB6BD /* TextFieldCell.m */,
689FBE881AB27283005CB6BD /* TextViewCell.h */,
689FBE891AB27283005CB6BD /* TextViewCell.m */,
689FBE8A1AB27283005CB6BD /* TitleFieldCell.h */,
689FBE8B1AB27283005CB6BD /* TitleFieldCell.m */,
689FBE881AB27283005CB6BD /* TextViewCell.h */,
689FBE8C1AB27283005CB6BD /* UrlFieldCell.h */,
689FBE8D1AB27283005CB6BD /* UrlFieldCell.m */,
5271A98C1ED7CA3E00B9AF2C /* TextFieldCell.xib */,
);
path = Cells;
sourceTree = "<group>";
Expand Down Expand Up @@ -900,11 +903,12 @@
689DFFCC13A4273F005EBD36 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = Self;
TargetAttributes = {
689DFFD413A4273F005EBD36 = {
DevelopmentTeam = G9ZT7943FZ;
LastSwiftMigration = 0830;
SystemCapabilities = {
com.apple.iCloud = {
enabled = 0;
Expand Down Expand Up @@ -995,6 +999,7 @@
689EA6941D67F94600CF445E /* Settings.storyboard in Resources */,
4E8C169416B3E871004195A1 /* fr-dropbox.html in Resources */,
4E8C169516B3E871004195A1 /* fr-itunes.html in Resources */,
5271A98D1ED7CA3E00B9AF2C /* TextFieldCell.xib in Resources */,
680C9D7A1D69E36C0040FB43 /* Help.storyboard in Resources */,
4E8C169616B3E871004195A1 /* fr-keyfiles.html in Resources */,
4E8C169716B3E871004195A1 /* fr-safariemail.html in Resources */,
Expand Down Expand Up @@ -1170,6 +1175,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -1179,8 +1185,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
Expand All @@ -1190,6 +1198,7 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand All @@ -1214,6 +1223,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand All @@ -1223,8 +1233,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
Expand All @@ -1233,6 +1245,7 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -1244,6 +1257,7 @@
METAL_ENABLE_DEBUG_INFO = NO;
PROVISIONING_PROFILE = "4758DC3A-B5A3-47FC-BA60-308A27C51D17";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -1257,14 +1271,17 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = G9ZT7943FZ;
INFOPLIST_FILE = "MiniKeePass/MiniKeePass-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.jflan.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE = "5443260a-ff69-4503-8b4b-2b598dc5db88";
PROVISIONING_PROFILE_SPECIFIER = "Flush Software Development: *";
SWIFT_OBJC_BRIDGING_HEADER = "MiniKeePass/MiniKeePass-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -1275,15 +1292,18 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = G9ZT7943FZ;
INFOPLIST_FILE = "MiniKeePass/MiniKeePass-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.jflan.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "29c6de49-d5a6-4b63-9168-72d9368ab499";
PROVISIONING_PROFILE = "5443260a-ff69-4503-8b4b-2b598dc5db88";
PROVISIONING_PROFILE_SPECIFIER = "Flush Software Development: *";
SWIFT_OBJC_BRIDGING_HEADER = "MiniKeePass/MiniKeePass-Bridging-Header.h";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion MiniKeePass/Cells/TextFieldCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@interface TextFieldCell : UITableViewCell <UITextFieldDelegate, UIActionSheetDelegate>

@property (nonatomic, copy) NSString *title;
@property (nonatomic, strong) UITextField *textField;
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (nonatomic, unsafe_unretained) id<TextFieldCellDelegate> textFieldCellDelegate;

@property (nonatomic, strong) UIButton *accessoryButton;
Expand Down
30 changes: 7 additions & 23 deletions MiniKeePass/Cells/TextFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,17 @@

@interface TextFieldCell()
@property (nonatomic, strong) UIView *grayBar;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@end

@implementation TextFieldCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
int inset;
if (SYSTEM_VERSION_LESS_THAN(@"7.0")) {
inset = 83;
} else {
inset = 115;
}

CGRect frame = self.contentView.frame;
frame.origin.x = inset;
frame.size.width -= inset;

_textField = [[UITextField alloc] initWithFrame:frame];
_textField.delegate = self;
_textField.autocorrectionType = UITextAutocorrectionTypeNo;
_textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
_textField.textColor = [UIColor colorWithRed:.285 green:.376 blue:.541 alpha:1];
_textField.font = [UIFont systemFontOfSize:16];
_textField.returnKeyType = UIReturnKeyNext;
_textField.clearButtonMode = UITextFieldViewModeWhileEditing;
_textField.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
_textField.font = [UIFont boldSystemFontOfSize:15];
_textField.textColor = [UIColor blackColor];
int inset = 110;

[self.contentView addSubview:self.textField];

CGFloat grayIntensity = 202.0 / 255.0;
UIColor *color = [UIColor colorWithRed:grayIntensity green:grayIntensity blue:grayIntensity alpha:1];

Expand Down Expand Up @@ -87,6 +66,11 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
return hitView;
}

- (void)setTitle:(NSString *)title {
_title = title;
_titleLabel.text = title;
}

- (BOOL)showGrayBar {
return !self.grayBar.hidden;
}
Expand Down
55 changes: 55 additions & 0 deletions MiniKeePass/Cells/TextFieldCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="ipad9_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="8tx-rg-lio" customClass="TextFieldCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" layoutMarginsFollowReadableWidth="YES" tableViewCell="8tx-rg-lio" id="2ih-Pm-hjK">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gtp-O0-2rs">
<rect key="frame" x="8" y="13.5" width="80" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="OC9-Ya-Kbj"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="14"/>
<color key="textColor" red="0.0" green="0.47934520244598389" blue="0.99908632040023804" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="pjs-Zs-MH3">
<rect key="frame" x="96" y="8" width="271" height="28"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<constraints>
<constraint firstAttribute="bottomMargin" secondItem="pjs-Zs-MH3" secondAttribute="bottom" id="AR5-YH-NSJ"/>
<constraint firstItem="pjs-Zs-MH3" firstAttribute="centerY" secondItem="2ih-Pm-hjK" secondAttribute="centerY" id="CHW-Cg-3DJ"/>
<constraint firstItem="Gtp-O0-2rs" firstAttribute="leading" secondItem="2ih-Pm-hjK" secondAttribute="leadingMargin" id="SDE-jd-aZl"/>
<constraint firstAttribute="trailingMargin" secondItem="pjs-Zs-MH3" secondAttribute="trailing" id="ZGa-b5-hv2"/>
<constraint firstItem="pjs-Zs-MH3" firstAttribute="top" secondItem="2ih-Pm-hjK" secondAttribute="topMargin" id="aJc-w1-h1V"/>
<constraint firstItem="pjs-Zs-MH3" firstAttribute="leading" secondItem="Gtp-O0-2rs" secondAttribute="trailing" constant="8" symbolic="YES" id="ePl-Ub-FVn"/>
<constraint firstItem="Gtp-O0-2rs" firstAttribute="centerY" secondItem="pjs-Zs-MH3" secondAttribute="centerY" id="iub-wt-pAM"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="textField" destination="pjs-Zs-MH3" id="VU3-R3-9y3"/>
<outlet property="titleLabel" destination="Gtp-O0-2rs" id="vXh-ig-ZEb"/>
</connections>
<point key="canvasLocation" x="-192" y="-114"/>
</tableViewCell>
</objects>
</document>
Loading

0 comments on commit dfe6085

Please sign in to comment.