Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
7c8da3a2
Commit
7c8da3a2
authored
Jun 03, 2016
by
Brent Gulanowski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #208 from Shopify/task/swift-sample
Fixes for Swift Sample app
parents
a2e76401
f5da46b2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
ViewController.swift
...pp Swift/Mobile Buy SDK Swift Sample/ViewController.swift
+10
-11
No files found.
Mobile Buy SDK Sample Apps/Sample App Swift/Mobile Buy SDK Swift Sample/ViewController.swift
View file @
7c8da3a2
...
@@ -37,13 +37,15 @@ class ViewController: UIViewController {
...
@@ -37,13 +37,15 @@ class ViewController: UIViewController {
let
channelId
=
""
let
channelId
=
""
let
productId
=
""
let
productId
=
""
let
modelManager
=
BUYModelManager
()
var
productVariant
:
BUYProductVariant
?
var
productVariant
:
BUYProductVariant
?
let
client
:
BUYClient
let
client
:
BUYClient
required
init
(
coder
aDecoder
:
NSCoder
)
{
required
init
(
coder
aDecoder
:
NSCoder
)
{
client
=
BUYClient
(
shopDomain
:
shopDomain
,
apiKey
:
apiKey
,
channelId
:
channel
Id
)
client
=
BUYClient
(
shopDomain
:
shopDomain
,
apiKey
:
apiKey
,
appId
:
app
Id
)
super
.
init
(
coder
:
aDecoder
)
!
super
.
init
(
coder
:
aDecoder
)
!
}
}
...
@@ -54,17 +56,15 @@ class ViewController: UIViewController {
...
@@ -54,17 +56,15 @@ class ViewController: UIViewController {
client
.
getProductById
(
productId
)
{
(
product
,
error
)
->
Void
in
client
.
getProductById
(
productId
)
{
(
product
,
error
)
->
Void
in
self
.
titleLabel
.
text
=
product
.
title
if
let
variants
=
product
.
variants
as?
[
BUYProductVariant
]
{
self
.
titleLabel
.
text
=
product
?
.
title
self
.
productVariant
=
variants
.
first
self
.
productVariant
=
product
?
.
variants
.
objectAtIndex
(
0
)
as!
BUYProductVariant
?
}
if
(
product
!=
nil
&&
error
==
nil
)
{
if
(
product
!=
nil
&&
error
==
nil
)
{
dispatch_async
(
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
))
{
dispatch_async
(
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
))
{
let
images
=
product
.
images
as
NSArray
let
images
=
product
?
.
images
let
buyImage
=
images
.
firstObject
as!
BUYImage
let
buyImage
=
images
?
.
firstObject
as!
BUYImageLink
let
url
=
NSURL
(
string
:
buyImage
.
src
!
)
let
url
=
NSURL
(
string
:
buyImage
.
src
!
)
let
data
=
NSData
(
contentsOfURL
:
url
!
)
let
data
=
NSData
(
contentsOfURL
:
url
!
)
...
@@ -82,18 +82,17 @@ class ViewController: UIViewController {
...
@@ -82,18 +82,17 @@ class ViewController: UIViewController {
@IBAction
func
didTapCheckout
(
sender
:
UIButton
)
{
@IBAction
func
didTapCheckout
(
sender
:
UIButton
)
{
// Create the checkout
// Create the checkout
let
cart
=
BUYCart
()
let
cart
=
modelManager
.
buy_objectWithEntityName
(
BUYCart
.
entityName
(),
JSONDictionary
:
nil
)
as!
BUYCart
cart
.
addVariant
(
productVariant
!
)
cart
.
addVariant
(
productVariant
!
)
let
checkout
=
BUYCheckout
(
cart
:
cart
)
let
checkout
=
BUYCheckout
(
cart
:
cart
)
client
.
createCheckout
(
checkout
)
{
(
checkout
,
error
)
->
Void
in
client
.
createCheckout
(
checkout
)
{
(
checkout
,
error
)
->
Void
in
let
checkoutURL
=
checkout
.
webCheckoutURL
if
let
checkoutURL
=
checkout
?
.
webCheckoutURL
{
if
(
UIApplication
.
sharedApplication
()
.
canOpenURL
(
checkoutURL
))
{
if
(
UIApplication
.
sharedApplication
()
.
canOpenURL
(
checkoutURL
))
{
UIApplication
.
sharedApplication
()
.
openURL
(
checkoutURL
)
UIApplication
.
sharedApplication
()
.
openURL
(
checkoutURL
)
}
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment