Skip to content

Commit f00dbdf

Browse files
committed
Save ipAddress and port to UserDefaults
1 parent 3b62617 commit f00dbdf

File tree

5 files changed

+70
-31
lines changed

5 files changed

+70
-31
lines changed

Examples/iOS/OSCTest/OSCTest.xcodeproj/project.pbxproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
TargetAttributes = {
125125
031ABE6B1FB64DC7005184D4 = {
126126
CreatedOnToolsVersion = 9.1;
127-
LastSwiftMigration = 1010;
127+
LastSwiftMigration = 1030;
128128
ProvisioningStyle = Automatic;
129129
};
130130
};
@@ -309,12 +309,12 @@
309309
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
310310
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
311311
CODE_SIGN_STYLE = Automatic;
312-
DEVELOPMENT_TEAM = 638F7EDPVY;
312+
DEVELOPMENT_TEAM = M4VH59A389;
313313
INFOPLIST_FILE = OSCTest/Info.plist;
314314
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
315-
PRODUCT_BUNDLE_IDENTIFIER = com.swiftosc.OSCTest;
315+
PRODUCT_BUNDLE_IDENTIFIER = com.swiftosc.OSCTestOld;
316316
PRODUCT_NAME = "$(TARGET_NAME)";
317-
SWIFT_VERSION = 4.2;
317+
SWIFT_VERSION = 5.0;
318318
TARGETED_DEVICE_FAMILY = "1,2";
319319
};
320320
name = Debug;
@@ -325,12 +325,12 @@
325325
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
326326
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
327327
CODE_SIGN_STYLE = Automatic;
328-
DEVELOPMENT_TEAM = 638F7EDPVY;
328+
DEVELOPMENT_TEAM = M4VH59A389;
329329
INFOPLIST_FILE = OSCTest/Info.plist;
330330
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
331-
PRODUCT_BUNDLE_IDENTIFIER = com.swiftosc.OSCTest;
331+
PRODUCT_BUNDLE_IDENTIFIER = com.swiftosc.OSCTestOld;
332332
PRODUCT_NAME = "$(TARGET_NAME)";
333-
SWIFT_VERSION = 4.2;
333+
SWIFT_VERSION = 5.0;
334334
TARGETED_DEVICE_FAMILY = "1,2";
335335
};
336336
name = Release;

Examples/iOS/OSCTest/OSCTest/Base.lproj/Main.storyboard

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3-
<device id="ipad12_9" orientation="portrait">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_5" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
99
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
1010
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1111
</dependencies>
@@ -15,36 +15,36 @@
1515
<objects>
1616
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="OSCTest" customModuleProvider="target" sceneMemberID="viewController">
1717
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
18-
<rect key="frame" x="0.0" y="0.0" width="1024" height="1366"/>
18+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
1919
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2020
<subviews>
2121
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="puF-04-U6e">
22-
<rect key="frame" x="38" y="330.5" width="948" height="31"/>
22+
<rect key="frame" x="38" y="354.66666666666669" width="338" height="31"/>
2323
<connections>
2424
<action selector="slider:" destination="BYZ-38-t0r" eventType="valueChanged" id="zlf-Jh-YSR"/>
2525
</connections>
2626
</slider>
2727
<stepper opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="sKM-kg-Mqo">
28-
<rect key="frame" x="465" y="261.5" width="94" height="29"/>
28+
<rect key="frame" x="160" y="285.66666666666669" width="94" height="29"/>
2929
<connections>
3030
<action selector="stepper:" destination="BYZ-38-t0r" eventType="valueChanged" id="z5b-P3-GNQ"/>
3131
</connections>
3232
</stepper>
3333
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eqh-db-cUa">
34-
<rect key="frame" x="485" y="471.5" width="54" height="30"/>
34+
<rect key="frame" x="180" y="495.66666666666669" width="54" height="30.000000000000057"/>
3535
<state key="normal" title="Impulse"/>
3636
<connections>
3737
<action selector="impulse:" destination="BYZ-38-t0r" eventType="touchUpInside" id="NAo-6W-vdj"/>
3838
</connections>
3939
</button>
4040
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rRs-0F-Qnh">
41-
<rect key="frame" x="487.5" y="400.5" width="51" height="31"/>
41+
<rect key="frame" x="182.66666666666663" y="424.66666666666669" width="51" height="31"/>
4242
<connections>
4343
<action selector="switcher:" destination="BYZ-38-t0r" eventType="valueChanged" id="ffC-LT-op0"/>
4444
</connections>
4545
</switch>
4646
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="9MP-YM-6LL">
47-
<rect key="frame" x="40" y="541.5" width="944" height="30"/>
47+
<rect key="frame" x="40" y="565.66666666666663" width="334" height="30"/>
4848
<nil key="textColor"/>
4949
<fontDescription key="fontDescription" type="system" pointSize="14"/>
5050
<textInputTraits key="textInputTraits"/>
@@ -54,14 +54,14 @@
5454
</connections>
5555
</textField>
5656
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6D4-SP-5Io">
57-
<rect key="frame" x="478" y="581.5" width="68" height="30"/>
57+
<rect key="frame" x="173" y="605.66666666666663" width="68" height="30"/>
5858
<state key="normal" title="Send Text"/>
5959
<connections>
6060
<action selector="sendText:" destination="BYZ-38-t0r" eventType="touchUpInside" id="LF2-IR-fsF"/>
6161
</connections>
6262
</button>
6363
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="/" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="k0E-UG-Frx">
64-
<rect key="frame" x="40" y="191.5" width="944" height="30"/>
64+
<rect key="frame" x="40" y="215.66666666666666" width="334" height="30"/>
6565
<nil key="textColor"/>
6666
<fontDescription key="fontDescription" type="system" pointSize="14"/>
6767
<textInputTraits key="textInputTraits"/>
@@ -71,13 +71,13 @@
7171
</connections>
7272
</textField>
7373
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Address Pattern" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gsn-9C-wqG">
74-
<rect key="frame" x="450.5" y="161" width="123" height="20.5"/>
74+
<rect key="frame" x="145.66666666666663" y="185" width="122.99999999999997" height="20.666666666666657"/>
7575
<fontDescription key="fontDescription" type="system" pointSize="17"/>
7676
<nil key="textColor"/>
7777
<nil key="highlightedColor"/>
7878
</label>
7979
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="localhost" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="weZ-5y-gEI">
80-
<rect key="frame" x="40" y="91" width="824" height="30"/>
80+
<rect key="frame" x="40" y="115" width="214" height="30"/>
8181
<nil key="textColor"/>
8282
<fontDescription key="fontDescription" type="system" pointSize="14"/>
8383
<textInputTraits key="textInputTraits"/>
@@ -87,7 +87,7 @@
8787
</connections>
8888
</textField>
8989
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="8080" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="RiS-Li-w7q">
90-
<rect key="frame" x="884" y="91" width="100" height="30"/>
90+
<rect key="frame" x="274" y="115" width="100" height="30"/>
9191
<nil key="textColor"/>
9292
<fontDescription key="fontDescription" type="system" pointSize="14"/>
9393
<textInputTraits key="textInputTraits"/>
@@ -97,13 +97,13 @@
9797
</connections>
9898
</textField>
9999
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Port" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TAe-LD-kcV">
100-
<rect key="frame" x="917.5" y="60" width="33" height="21"/>
100+
<rect key="frame" x="307.66666666666674" y="84" width="33" height="21"/>
101101
<fontDescription key="fontDescription" type="system" pointSize="17"/>
102102
<nil key="textColor"/>
103103
<nil key="highlightedColor"/>
104104
</label>
105105
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="IP Address" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ss4-Ie-2mh">
106-
<rect key="frame" x="411" y="60" width="82" height="21"/>
106+
<rect key="frame" x="106" y="84" width="82" height="21"/>
107107
<fontDescription key="fontDescription" type="system" pointSize="17"/>
108108
<nil key="textColor"/>
109109
<nil key="highlightedColor"/>
@@ -148,6 +148,11 @@
148148
</constraints>
149149
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
150150
</view>
151+
<connections>
152+
<outlet property="addressPatternLabel" destination="k0E-UG-Frx" id="mfQ-S8-UbM"/>
153+
<outlet property="ipAddressLabel" destination="weZ-5y-gEI" id="fMn-X7-NsN"/>
154+
<outlet property="portLabel" destination="RiS-Li-w7q" id="n65-lS-PGr"/>
155+
</connections>
151156
</viewController>
152157
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
153158
</objects>

Examples/iOS/OSCTest/OSCTest/ViewController.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,46 @@ var address = OSCAddressPattern("/")
1818

1919
class ViewController: UIViewController {
2020

21+
// User defaults
22+
private var defaults = UserDefaults.standard
23+
2124
//Variables
2225
var ipAddress = "localhost"
2326
var port = 8080
2427
var text = ""
28+
29+
// UI Elements
30+
@IBOutlet weak var ipAddressLabel: UITextField!
31+
@IBOutlet weak var portLabel: UITextField!
32+
@IBOutlet weak var addressPatternLabel: UITextField!
33+
2534

2635
override func viewDidLoad() {
2736
super.viewDidLoad()
2837
// Do any additional setup after loading the view, typically from a nib.
38+
39+
// Get defaults and set Labels
40+
if let ipAddress = defaults.string(forKey: "ipAddress") {
41+
42+
if ipAddress == "" {
43+
self.ipAddress = "localhost"
44+
}
45+
ipAddressLabel.text = ipAddress
46+
}
47+
port = defaults.integer(forKey: "port")
48+
print(port)
49+
if port == 0 {
50+
self.port = 8080
51+
}
52+
portLabel.text = String(port)
53+
54+
client = OSCClient(address: ipAddress, port: port)
55+
56+
_ = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { (_) in
57+
let message = OSCMessage(address, 0, 0.0, true, "hello world")
58+
client.send(message)
59+
}
60+
2961
}
3062

3163
override func didReceiveMemoryWarning() {
@@ -39,6 +71,8 @@ class ViewController: UIViewController {
3971
if let text = sender.text {
4072
ipAddress = text
4173
client = OSCClient(address: ipAddress, port: port)
74+
75+
defaults.set(ipAddress, forKey: "ipAddress")
4276
}
4377
}
4478

@@ -49,6 +83,8 @@ class ViewController: UIViewController {
4983
print(number)
5084
port = number
5185
client = OSCClient(address: ipAddress, port: port)
86+
87+
defaults.set(port, forKey: "port")
5288
}
5389
}
5490
}

Examples/macOS/OSCMonitor/OSCMonitor.xcodeproj/project.pbxproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
CreatedOnToolsVersion = 8.0;
127127
DevelopmentTeam = 638F7EDPVY;
128128
DevelopmentTeamName = "Devin Roth (Personal Team)";
129-
LastSwiftMigration = 0910;
129+
LastSwiftMigration = 1030;
130130
ProvisioningStyle = Automatic;
131131
};
132132
};
@@ -305,8 +305,7 @@
305305
MACOSX_DEPLOYMENT_TARGET = 10.11;
306306
PRODUCT_BUNDLE_IDENTIFIER = com.swiftosc.OSCMonitor;
307307
PRODUCT_NAME = "$(TARGET_NAME)";
308-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
309-
SWIFT_VERSION = 4.0;
308+
SWIFT_VERSION = 5.0;
310309
};
311310
name = Debug;
312311
};
@@ -321,8 +320,7 @@
321320
MACOSX_DEPLOYMENT_TARGET = 10.11;
322321
PRODUCT_BUNDLE_IDENTIFIER = com.swiftosc.OSCMonitor;
323322
PRODUCT_NAME = "$(TARGET_NAME)";
324-
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
325-
SWIFT_VERSION = 4.0;
323+
SWIFT_VERSION = 5.0;
326324
};
327325
name = Release;
328326
};

Framework/iOS/iOS.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
TargetAttributes = {
205205
036486751F820BBD00F3D6CE = {
206206
CreatedOnToolsVersion = 9.0;
207-
LastSwiftMigration = 1000;
207+
LastSwiftMigration = 1030;
208208
ProvisioningStyle = Automatic;
209209
};
210210
};
@@ -402,7 +402,7 @@
402402
PRODUCT_BUNDLE_IDENTIFIER = com.devinrothmusic.SwiftOSCiOS;
403403
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
404404
SKIP_INSTALL = YES;
405-
SWIFT_VERSION = 4.2;
405+
SWIFT_VERSION = 5.0;
406406
TARGETED_DEVICE_FAMILY = "1,2";
407407
};
408408
name = Debug;
@@ -424,7 +424,7 @@
424424
PRODUCT_BUNDLE_IDENTIFIER = com.devinrothmusic.SwiftOSCiOS;
425425
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
426426
SKIP_INSTALL = YES;
427-
SWIFT_VERSION = 4.2;
427+
SWIFT_VERSION = 5.0;
428428
TARGETED_DEVICE_FAMILY = "1,2";
429429
};
430430
name = Release;

0 commit comments

Comments
 (0)