Swift is a programming language designed by Apple for creating iOS and OS X apps. Swift retains some elements from C and Objective-C, but offers many modern features such as generics, closures, optionals, tuples, type inference, and operator overloading.

learn more… | top users | synonyms (2)

0
votes
0answers
4 views

I'm currently checking if UIAlertController exists to determine what OS version is being used. Is there a more efficient way to do this?

I have a delete button on a cell and it was crashing my app in iOS7 but not in iOS8. I later found out the crash was caused by by how deep down I was digging into my view hierarchy. To make things ...
0
votes
0answers
4 views

Swift - How to pass parameters from appDelegate to ViewController?

I need to pass some parameters from the appDelegate to a viewController before loading it. This is the code i'm trying to use (in the appDelegate.swift): let storyboard = UIStoryboard(name: "Main", ...
0
votes
1answer
7 views

Why do I get an error when I'm trying to create a new instance of a parser

I implemented this class: class Category: NSObject { var attributeID:NSString = "" var nameCategory:NSString = "nameNotFound" var hasChild = false var children:[Category] = [] } And ...
0
votes
0answers
19 views

Something strange happening when assigning title to UIViewController

I am having some viewControllers each connected by segues. The rootViewController is connected to the NavigationController. Now, in one UIViewController, I am performing a segue to go to another ...
0
votes
1answer
10 views

Issue with genstrings for Swift file

genstrings works well to extract localizable content from .m file as, find . -name \*.m | xargs genstrings -o en.lproj But, not working for .swift file as, find . -name \*.swift | xargs ...
0
votes
2answers
27 views

Create a UIView with only one diagonal side

I need to create a UIView that has the left border inclined with 45 degrees I was wondering,is there a way to acheive this programmatically? Does CATransform3D help me in this case since it’s not ...
0
votes
1answer
25 views

How to implement custom initialiser method of uiviewController in swift

How to implement the below objective-c init method in swift - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil withName:(NSString *)name { if (self = [self ...
0
votes
1answer
11 views

How do I write universal swift code for both iOS and OS X. In cocoa I could use #ifdef, what do I do now?

for our project we always used one source file for both platforms: iOS and OS X. Right now I am migrating to swift. Unfortunately there is some files which need import Cocoa and on iOS import ...
0
votes
0answers
14 views

Swift/BLE Notifications not working

I am using the Ti sensortag to play around with bluetooth and sensors. My goal is to get the barometer and the buttons working. The buttons notify when pressed but the barometer never notifies or ...
0
votes
0answers
22 views

Change the text of UINavigationController not working in Swift

I have an app which has 5 UIViewControllers and the rootViewController is attached to a UINavigationController and the others are connected by segues. Now, I want to add a title to the ...
0
votes
0answers
12 views

Swift / xcode - managing subviews within a single screen

I cannot grasp how to manage subviews within the same view so that data can be collected in a flexible data model (or collection of models, if each view must have its own model). The user should be ...
1
vote
1answer
12 views

Parser Element with child element

i have for example this document: <Category> <Name>NameParent</Name> <Category> <Category> <Name>NameChild1</Name> <Category> ...
1
vote
0answers
24 views

Difference between implicit and explicit return from single-expression Closure in Swift

I encountered strange problem with Swift compiler. This code failed to compile: let str = "012345,abc,officer" let components = split(str, { return $0 == "," }) // ^ error: 'NSString' ...
0
votes
1answer
15 views

In Swift fileExistsAtPath(_ path: String, isDirectory isDirectory: UnsafeMutablePointer<ObjCBool>) -> Bool accepts single parameter only

The method fileExistsAtPath() in the example below accept single argument only. if fm.fileExistsAtPath(result, isDirectory:&isDir) { The exact error message is: "Extra argument 'isDirectory' in ...
0
votes
0answers
14 views

custom keyboard subview remains fixed on size

I'm making a custom keyboard for iOS8. It all works, and all the buttons live in a view I made in a .xib file. In my code I grab that view and show it on my self.view, which is the keyboard area. ...
1
vote
2answers
29 views

How can I call a method from ViewController?

Is it possible to call a method (written in a Gamescene) from a ViewController in Swift? I read about Protocol, delegate or Inheritance but all tutorials I saw don't show this case. Thank you for ...
0
votes
1answer
17 views

Set enum from NSDictionary Swift

I have information stored in a plist file that I pull into a dictionary. I have a class with some enums set up as follows: enum componentPostion { case upperLeft, UpperRight, lowerLeft, ...
0
votes
1answer
25 views

Swift If Statement Not Working with UILabel

My if statement is not displaying what I want it to. Can anyone help? I want to display some text in a UILabel that will be decided from weather the random number is below or above 50. Here is the ...
0
votes
0answers
3 views

Swift Get Video Frame use AVFoundation

This is my code: I want get my video and get the frame data to an SceneKit SCNSphere. //NSString videoPath=NSBundle.mainBundle().l var ...
0
votes
1answer
8 views

BLE writeValue to peripheral

I am having trouble to write values to a BLE device. I translated this: NSLog(@"Writing value for characteristic %@", interestingCharacteristic); [peripheral writeValue:dataToWrite ...
1
vote
1answer
17 views

Change colour of swipe-to-delete background in Swift

I have been trying to change the colour of the background of the swipe to delete button in my tableview. I took a look at some Objective-C examples but I haven't been able to translate them into ...
0
votes
1answer
18 views

How to define a return type of a function which contains another, no parameter, function in Swift?

How should I define the return type of createMyFunction in the following code in Swift? Tried (() -> Int), but I get "Expression resolves to an unused function" error when I call createMyFunction() in ...
0
votes
1answer
23 views

Mail compose view controller text colour won't change

I have a support feature in my app that allows users to email for support regarding the app via email. The issue is that while the rest of my app have white navigation bar text, the text in the ...
1
vote
0answers
25 views

Custom Seque, scaling out the source view controller

Attempting to write a custom segue where the source view is scaled out, whilst changing the alpha of the destination to fade the destination in. The destination is a MKMapView, so I want it updating ...
0
votes
2answers
30 views

Swift global variable

I'm new in swift. I would like to figure out how to reuse this variable (item) in other ways: if var item = currentItem?.listCategoryScheme[countCategoryScheme].listCategory{ ... ...
0
votes
0answers
8 views

How to find which image is moved from the view?

I am developing a puzzle game and I want to detect which image is moved by the user so that I can get the tag value from it which is assigned into dictionary and I can make its bool true when it goes ...
2
votes
1answer
26 views

IB outlet collection do not have indexOfObject

Why IB outlet collection do not have index of object method when it is an array? What I am doing wrong? @IBOutlet var textFieldsCollection: [UITextField]! ...
0
votes
0answers
12 views

Can not cast imported entity in test

I have a very simple app in Swift using Core Data. I am creating a test where I want to check that entities are properly imported from a JSON file. I am getting "EXC_BAD_INSTRUCTION ...
1
vote
1answer
32 views

“'CGFloat' is not convertible to 'Double'” error in SWIFT (iOS)

Im trying to cut an image into 9 pieces in SWIFT. Im getting this error "'CGFloat' is not convertible to 'Double'". I get this error when I put "i" or "j" in the two variables. Below is part of the ...
0
votes
0answers
11 views

ViewController on the left submenu on the right video in swift

How can i do on ViewController on the left submenu on the right playing video i don't know how to place two other views in one ViewController plz help...thanx Landscape image1 portrait image2 ...
0
votes
0answers
17 views

how to upload images to a server in iOS swift

It won't work, how to send an image from an iOS swift app to my PHP server @IBAction func upload(sender: UIButton) { var imageData = UIImageJPEGRepresentation(img.image, 90) // ...
-2
votes
3answers
27 views

Setting Title of UIbuttons in loop in swift

I have made a collection of UIButtons like this @IBOutlet var btnChannle1:UIButton! @IBOutlet var btnChannle2:UIButton! @IBOutlet var btnChannle3:UIButton! @IBOutlet var btnChannle4:UIButton! ...
1
vote
0answers
9 views

Bridging issue while using AFNetworking with Pods in a Swift Project

I am facing problem when I initialise AFHTTPSessionManager in my swift class. I have added AFNetworking using pods in my project. It shows error use of undeclared type. But when I press CMD + Click on ...
0
votes
1answer
10 views

Simple SceneKit scene shows black screen instead of SCNPlane

I am getting my feet wet with iOS SceneKit, however the following sample code (which executes inside viewDidLoad) is not behaving as expected. I want it to place a camera at origin with direction ...
0
votes
1answer
12 views

How to display RGB Texture by OpenGL in Swift?

I want to display a RGB Texture by OpenGL in Swift, It was working fine in Objective-C, and I tried to porting the code to Swift Language, I can not really understand how to pass the values to ...
1
vote
0answers
16 views

Spacing between blocks in Swift 100% width

Im testing some stuff for an app in SWIFT. My goal is to have the full screen covered in blocks, so it give a 100% width and height. but for some reason, theres always 1px or 2px spacing. I think its ...
2
votes
2answers
25 views

How to compare CGPoints In swift?

I have 2 CGPoint like : let a : CGPoint = CGPointMake(1, 1) let b : CGPoint = CGPointMake(1, 1) if Both are same then I want to do something. This is just an example but I want to compare this ...
-3
votes
1answer
42 views

Why does (“0”+“1”).toInt()! return 1 as an Int, rather than 0

Was playing around with the reduce function on collections in Swift. //Reduce method should return an Int with the value 3141. let digits = ["3", "1", "4", "1"] .reduce(0) { (total:Int, ...
0
votes
0answers
25 views

How to place Images Randomly In puzzle game?

I am developing a puzzle game where I places 4 Images like : @IBOutlet var Image1: UIImageView! @IBOutlet var Image2: UIImageView! @IBOutlet var Image3: UIImageView! @IBOutlet var Image4: ...
0
votes
0answers
12 views

services discovered while scanning hardware shows device unknown despite showing 180D using core bluetooth framework ios

I am scanning hardware device using core bluetooth framework yesterday I found it was showing 2 services heart rate and device information and today showing 1 as device unknown instead of heart ...
0
votes
0answers
6 views

Issue capturing video with UIImagePicker with custom camera controls

I've created a UIImagePickerController with a custom overlay, and I want to take both pictures and video with it. I can take pictures without issue, but when I try to take video, I get the following ...
2
votes
2answers
34 views

Where do you put a global method in swift?

I have a function that is common to all my controllers: func myColor() -> UIColor { return UIColor(red: 9.0/255.0, green: 134.0/255.0, blue: 255.0/255.0, alpha: 1) } Where can I put this ...
0
votes
2answers
41 views

In Swift optional function in block raises error

Following is the test code: In the first one, the onComplete function is not optional, everything is fine. However, in the second one, an error occurs. Could anyone explain to me? Updated The ...
0
votes
4answers
35 views

Working with UIAlertView in swift

I am a new IOS dev with little experience in Objective C, but now I am starting to learn swift instead. I am making a test app with a bunch of different basic features just so I can get used to the ...
0
votes
1answer
23 views

Go to another ViewController Swift

i have a ViewController where in the ViewDidLoad i call a method to evaluate TouchID policy. I have made in storyboard a tab bar controller with 3 tabs. I want to go to the tab bar controller if ...
0
votes
0answers
11 views

SecItemUpdate() keeps returning errSecParam and I can't figure out why

Here is the entire function responsible for adding the value into the encrypted store. This is running on the iPhone6 Simulator in XCode 6. func addOrUpdateGenericPassword(password: String, ...
-1
votes
0answers
93 views

Displaying high school block rotation in Swift UITableView [on hold]

I'm working on an application unofficially for my school to better learn and test my skills of the Swift programming language. I hate having to memorize which classes I have and when, and most ...
0
votes
1answer
33 views

Get string from userInfo Dictionary

I have a userInfo dictionary from a UILocalNotification. Is there an easy way to get the String value when using implicit unwrapping? if let s = userInfo?["ID"] Gives me a AnyObject that I have ...
0
votes
1answer
23 views

Edit in cell text UITableViewCell Xcode 6

So I've got no clue how to work this code around I've CMD+Clicked on UITableViewDelegate And thought I could use this method: func tableView(tableView: UITableView, editingStyleForRowAtIndexPath ...
2
votes
3answers
37 views

Swift functions accepting tuples

Is it possible to pass in a tuple into a function as long as their types match up? When I try it, I get a missing argument in parameter error: var myTuple = ("Text",10,"More Text") func ...