Skip to content

Commit 3003191

Browse files
committed
Make CrowdCountMac app because playgrounds are so fickle
Kept getting linker errors: https://gist.github.com/dimroc/6ab526e66116765f90fb2440837a0cca
1 parent d409503 commit 3003191

File tree

15 files changed

+680
-7
lines changed

15 files changed

+680
-7
lines changed

ios/CrowdCount.xcodeproj/project.pbxproj

+231
Large diffs are not rendered by default.

ios/CrowdCountApi/PredictionStrategy.swift

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extension PredictionStrategy {
1919
public var friendlyName: String {
2020
return String(describing: self)
2121
.replacingOccurrences(of: "CrowdCountApi.", with: "")
22+
.replacingOccurrences(of: "CrowdCountApiMac.", with: "")
2223
.replacingOccurrences(of: "PredictionStrategy", with: "")
2324
}
2425

ios/CrowdCountApi/Utils/Duration.swift

+2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ public class Duration {
44
private let depth: Int
55
private var timingStack = [(startTime:Double, name:String, reported:Bool)]()
66

7+
@discardableResult
78
public static func measure(_ name: String, depth: Int = 0, block: () -> Void) -> Double {
89
let duration = Duration(depth)
910
duration.startMeasurement(name)
1011
block()
1112
return duration.stopMeasurement()
1213
}
1314

15+
@discardableResult
1416
public static func measureAndReturn<T>(_ name: String, depth: Int = 0, block: () -> T) -> T {
1517
let duration = Duration(depth)
1618
duration.startMeasurement(name)

ios/CrowdCountMac/AppDelegate.swift

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// AppDelegate.swift
3+
// CrowdCountMac
4+
//
5+
// Created by Dimitri Roche on 8/12/18.
6+
// Copyright © 2018 Dimitri Roche. All rights reserved.
7+
//
8+
9+
import Cocoa
10+
import Cartography
11+
12+
@NSApplicationMain
13+
class AppDelegate: NSObject, NSApplicationDelegate {
14+
15+
@IBOutlet weak var window: NSWindow!
16+
let vc = DragDropViewController()
17+
18+
func applicationDidFinishLaunching(_ aNotification: Notification) {
19+
window.contentViewController = vc
20+
}
21+
22+
func applicationWillTerminate(_ aNotification: Notification) {
23+
// Insert code here to tear down your application
24+
}
25+
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"size" : "16x16",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"size" : "16x16",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"size" : "32x32",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"size" : "32x32",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"size" : "128x128",
26+
"scale" : "1x"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"size" : "128x128",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"size" : "256x256",
36+
"scale" : "1x"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"size" : "256x256",
41+
"scale" : "2x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"size" : "512x512",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"size" : "512x512",
51+
"scale" : "2x"
52+
}
53+
],
54+
"info" : {
55+
"version" : 1,
56+
"author" : "xcode"
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.3.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.3.2"/>
5+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6+
</dependencies>
7+
<objects>
8+
<customObject id="-2" userLabel="File's Owner" customClass="DragDropViewController" customModule="Crowd_Count" customModuleProvider="target">
9+
<connections>
10+
<outlet property="imageWell" destination="tmM-56-WMo" id="FSD-w9-Q8d"/>
11+
<outlet property="predictionLabel" destination="for-DB-XJS" id="aXl-64-5ke"/>
12+
<outlet property="stackView" destination="ZgG-JC-WHg" id="KPO-sN-qh5"/>
13+
<outlet property="view" destination="c22-O7-iKe" id="Tih-bX-s0g"/>
14+
</connections>
15+
</customObject>
16+
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
17+
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
18+
<customView id="c22-O7-iKe">
19+
<rect key="frame" x="0.0" y="0.0" width="600" height="475"/>
20+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
21+
<subviews>
22+
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="q7e-VA-Hkc">
23+
<rect key="frame" x="0.0" y="0.0" width="600" height="475"/>
24+
<clipView key="contentView" id="PEj-yI-RqR">
25+
<rect key="frame" x="1" y="1" width="598" height="473"/>
26+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
27+
<subviews>
28+
<stackView distribution="fillProportionally" orientation="vertical" alignment="centerX" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZgG-JC-WHg">
29+
<rect key="frame" x="0.0" y="-2" width="598" height="475"/>
30+
<subviews>
31+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="IDJ-z3-Nuh">
32+
<rect key="frame" x="116" y="416" width="366" height="39"/>
33+
<constraints>
34+
<constraint firstAttribute="height" constant="39" id="Z7z-a6-UOs"/>
35+
</constraints>
36+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Drag in an image of a crowd" id="M7n-nN-27S">
37+
<font key="font" metaFont="systemUltraLight" size="32"/>
38+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
39+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
40+
</textFieldCell>
41+
</textField>
42+
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="tmM-56-WMo">
43+
<rect key="frame" x="74" y="61" width="450" height="338"/>
44+
<constraints>
45+
<constraint firstAttribute="width" constant="444" id="lX5-rT-MFp"/>
46+
<constraint firstAttribute="height" constant="332" id="vPX-Mc-68A"/>
47+
</constraints>
48+
<imageCell key="cell" selectable="YES" editable="YES" alignment="left" imageScaling="proportionallyDown" imageFrameStyle="grayBezel" id="ZzE-tp-Vg1"/>
49+
</imageView>
50+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="3" translatesAutoresizingMaskIntoConstraints="NO" id="for-DB-XJS">
51+
<rect key="frame" x="219" y="20" width="161" height="24"/>
52+
<constraints>
53+
<constraint firstAttribute="height" constant="24" id="jlF-8x-hc0"/>
54+
</constraints>
55+
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Pending Prediction" placeholderString="Pending Prediction" id="Nvr-56-Phb">
56+
<font key="font" metaFont="systemUltraLight" size="20"/>
57+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
58+
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
59+
</textFieldCell>
60+
</textField>
61+
</subviews>
62+
<edgeInsets key="edgeInsets" left="0.0" right="0.0" top="20" bottom="20"/>
63+
<visibilityPriorities>
64+
<integer value="1000"/>
65+
<integer value="1000"/>
66+
<integer value="1000"/>
67+
</visibilityPriorities>
68+
<customSpacing>
69+
<real value="3.4028234663852886e+38"/>
70+
<real value="3.4028234663852886e+38"/>
71+
<real value="3.4028234663852886e+38"/>
72+
</customSpacing>
73+
</stackView>
74+
</subviews>
75+
<constraints>
76+
<constraint firstItem="ZgG-JC-WHg" firstAttribute="top" secondItem="PEj-yI-RqR" secondAttribute="top" id="7Af-uz-aMi"/>
77+
<constraint firstItem="ZgG-JC-WHg" firstAttribute="leading" secondItem="PEj-yI-RqR" secondAttribute="leading" id="FtZ-3c-S7X"/>
78+
<constraint firstItem="ZgG-JC-WHg" firstAttribute="width" secondItem="PEj-yI-RqR" secondAttribute="width" id="LfP-IO-XrI"/>
79+
</constraints>
80+
</clipView>
81+
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="pK8-I7-7nX">
82+
<rect key="frame" x="1" y="458" width="598" height="16"/>
83+
<autoresizingMask key="autoresizingMask"/>
84+
</scroller>
85+
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="oJV-K4-ewE">
86+
<rect key="frame" x="583" y="1" width="16" height="473"/>
87+
<autoresizingMask key="autoresizingMask"/>
88+
</scroller>
89+
</scrollView>
90+
</subviews>
91+
<constraints>
92+
<constraint firstItem="q7e-VA-Hkc" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="07R-kP-oTx"/>
93+
<constraint firstAttribute="trailing" secondItem="q7e-VA-Hkc" secondAttribute="trailing" id="0hh-Go-EMX"/>
94+
<constraint firstItem="q7e-VA-Hkc" firstAttribute="width" secondItem="c22-O7-iKe" secondAttribute="width" id="47P-4Q-lK3"/>
95+
<constraint firstItem="q7e-VA-Hkc" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="g9P-Df-0ux"/>
96+
<constraint firstAttribute="bottom" secondItem="q7e-VA-Hkc" secondAttribute="bottom" id="qza-iQ-MA0"/>
97+
</constraints>
98+
<point key="canvasLocation" x="222" y="667.5"/>
99+
</customView>
100+
<userDefaultsController representsSharedInstance="YES" id="6y6-34-9ce"/>
101+
</objects>
102+
</document>
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.3.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.3.2"/>
5+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
6+
</dependencies>
7+
<objects>
8+
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
9+
<connections>
10+
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
11+
</connections>
12+
</customObject>
13+
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
14+
<customObject id="-3" userLabel="Application"/>
15+
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="CrowdCountMac" customModuleProvider="target">
16+
<connections>
17+
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
18+
</connections>
19+
</customObject>
20+
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
21+
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
22+
<items>
23+
<menuItem title="Crowd Count" id="1Xt-HY-uBw">
24+
<modifierMask key="keyEquivalentModifierMask"/>
25+
<menu key="submenu" title="Crowd Count" systemMenu="apple" id="uQy-DD-JDr">
26+
<items>
27+
<menuItem title="About CrowdCountMac" id="5kV-Vb-QxS">
28+
<modifierMask key="keyEquivalentModifierMask"/>
29+
<connections>
30+
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
31+
</connections>
32+
</menuItem>
33+
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
34+
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
35+
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
36+
<menuItem title="Services" id="NMo-om-nkz">
37+
<modifierMask key="keyEquivalentModifierMask"/>
38+
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
39+
</menuItem>
40+
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
41+
<menuItem title="Hide CrowdCountMac" keyEquivalent="h" id="Olw-nP-bQN">
42+
<connections>
43+
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
44+
</connections>
45+
</menuItem>
46+
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
47+
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
48+
<connections>
49+
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
50+
</connections>
51+
</menuItem>
52+
<menuItem title="Show All" id="Kd2-mp-pUS">
53+
<modifierMask key="keyEquivalentModifierMask"/>
54+
<connections>
55+
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
56+
</connections>
57+
</menuItem>
58+
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
59+
<menuItem title="Quit CrowdCountMac" keyEquivalent="q" id="4sb-4s-VLi">
60+
<connections>
61+
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
62+
</connections>
63+
</menuItem>
64+
</items>
65+
</menu>
66+
</menuItem>
67+
</items>
68+
<point key="canvasLocation" x="-15" y="-324"/>
69+
</menu>
70+
<window title="Crowd Count" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
71+
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
72+
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
73+
<rect key="contentRect" x="335" y="390" width="400" height="400"/>
74+
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
75+
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
76+
<rect key="frame" x="0.0" y="0.0" width="400" height="400"/>
77+
<autoresizingMask key="autoresizingMask"/>
78+
</view>
79+
</window>
80+
</objects>
81+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
</dict>
10+
</plist>

0 commit comments

Comments
 (0)