UISwitch

Changing the colour of a UISwitch control.

#define kSwitchOnColor [UIColor colorWithRed:0.647 green:0.757 blue:0.463 alpha:1] // /*#A5C176*/ Green

#define kSwitchOffColor [UIColor colorWithRed:0.29 green:0.29 blue:0.525 alpha:1]; // /*#4A4A86*/ Purple
UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero];
[switchview setOn:TRUE animated:YES];
switchview.onTintColor = kSwitchOnColor;
switchview.tintColor = kSwitchOffColor;
//tintColor just does outline
switchview.backgroundColor = kSwitchOffColor;
switchview.layer.cornerRadius = 16.0f;

tintColor changes the background when sliding but when off just has the outline, if you change the background then it is square so add a corner radius.

Advertisements

API Clients – Chaining Requests

POSTMAN

https://www.getpostman.com/docs/chaining_requests

http://blog.getpostman.com/2014/01/27/extracting-data-from-responses-and-chaining-requests/

var jsonData = JSON.parse(responseBody);

postman.setEnvironmentVariable("token", jsonData.token);

 

Add

{{token}}

PAW

Variables from previous responses

https://paw.cloud/docs/environments/environments-from-responses

In the response view, right-click on the field you’re interested in and pick Copy as Response Body Dynamic Value

Swift Package Manager Notes

I’ve been running through the excellent tutorials from NSScreencast (@NSScreencast) on using the swift package manager.

I’ve ran into a couple of issues which I thought I’d share as others might also run into them and hopefully they will be of use.

Thanks to subdigital for the help whilst I’m learning.

I had a couple of issues with some gems in Ruby since macOS comes shipped with a lesser version.

Setup: https://gorails.com/setup/osx/10.12-sierra

Reboot once completed.

Next when I went to complete the second video in the series I’d realised I hadn’t set up a great folder structure.

I had Katas then the code I’d been working with for the first FizzBuzz, this really needs it’s own folder, I moved this over then made a copy for the updates to guard, should really be using source control but I haven’t for now.

I tried running

bundle exec guard init
bundle exec guard

But got an error when I tried updating any of the code

<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/AlexHedley/Documents/NSScreencast/Katas/FizzBuzz/.build/debug.yaml test
Failed

I asked ben for help and he pointed me in the right direction, this wasn’t an issue with ruby but with swift.

I ran

swift build

and got a better error to work with

:0: error: PCH was compiled with module cache path '/Users/AlexHedley/Documents/NSScreencast/Katas/.build/debug/ModuleCache/Q3KKH3V7UU86', but the path is currently '/Users/AlexHedley/Documents/NSScreencast/Katas/FizzBuzz Updated/.build/debug/ModuleCache/Q3KKH3V7UU86'

Looking around I found that I needed to delete the .build folder

http://stackoverflow.com/a/410…

then I ran

swift build
bundle exec guard init
bundle exec guard
 and everything was working.

Other things I looked at

Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData

http://stackoverflow.com/quest…

Would it be worth deleting the ModuleCache folder
/Users/AlexHedley/Library/Developer/Xcode/DerivedData/ModuleCache
http://meandmark.com/blog/2016…

Usually it can be resolved by holding down the Option key and choosing Product > Clean Build Folder…

http://stackoverflow.com/a/154…
Is there a way to do this for what we are using?


Completed Tutorials

Google Maps iOS SDK – Error

Google Maps iOS SDK

https://developers.google.com/maps/documentation/ios-sdk/start

Followed the setup instructions using Cocoa Pods.

GoogleMaps (2.1.1)
GooglePlaces (2.1.1)

Built the Project and got the following error:

Module ‘GoogleMapsBase’ not found

 

Added the following in:

Target -> Build Setting -> Search Path-> Framework Search Paths

Add the following (+)

Framework Search Paths

 "${PODS_ROOT}/GoogleMaps/Base/Frameworks"
 "${PODS_ROOT}/GoogleMaps/Maps/Frameworks"

Build and Run.


Helpful Links

 

Camera Access

Info.plist

Add a new item

Privacy – Camera Usage Description

Value: “Used to scan barcodes”

Or as XML

<key>NSCameraUsageDescription</key>
<string>Used to scan barcodes</string>

 

http://useyourloaf.com/blog/privacy-settings-in-ios-10/


Photo Access

<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>

 

 

Goals for 2017

  • 599CD (iOS)

Release it!

  • 599CD (Android)

Write an Android version of the iOS I’m hoping to release.

  • Wallet Jam Jar Cinema Passes

I’d like to write a Swift Server Side app to create Jam Jar Cinema passes (like CineWorld)

  • .NET apps (school tracking)

Goals for 2016 – Review

I created a post to motivate me to get things done.

https://alexhedley.wordpress.com/2016/01/01/goals-for-2016/

  • 599CD (iPad)

I’ve nearly completed this, it’s currently in the final rounds of testing and I’m happy with how it’s come out.

http://599cd.com/apple/iOS/

  • 599CD (Apple TV)

Updated to the new TVML xml files instead of JS, its semi-working, I’m thinking of making it a native app instead.

  • 599CD (Android)

Hoping to start it this year, I’ve got the Dev tools ready on my mac.

  • Sign Language (Apple TV)
  • Carcassonne Score Keeper (iOS/Mac)
  • Bowling Score Keeper (iOS)
  • Wanted to add an Apple Watch

These aren’t as much a priority anymore.

  • Movem App

I worked on this a lot and managed to get a majority of it working. All the levels are created and the app works, just needs some polish. I tried porting it to the AppleTV but the controls don’t quite work.

Now I need to upgrade it to Swift 3, fun times ahead.

I’ve been using my time to learn other things. A lot more C# Dev.

I’ve been enjoying Server Side Swift with a set of videos from Ray Wenderlich.

I’ve been running through the Swift Apprentice book with the Playgrounds app.