Swift is an open-source programming language developed by Apple. Use the tag only for questions about language features, or requiring code in Swift. Use the tags [ios], [osx], [watch-os], [tvos], [cocoa-touch], and [cocoa] for (language-agnostic) questions about the platforms or frameworks.

learn more… | top users | synonyms (3) | swift jobs

0
votes
0answers
11 views

How to set a custom class UIButton with another object of the same class?

I have a UITableView with customs cells: ParagraphTableViewCell. @IBDesignable class ParagraphTableViewCell: UITableViewCell { weak var delegate: ParagraphProtocol? var paragraph:Paragraph!...
1
vote
2answers
16 views

iOS - Filter array of objects which contains today's date only

Basically my challenge is : I got an array of objects . Each object has a date property . I want to get the array of objects which matches today's date. So, I want to group the array based on date. ...
0
votes
1answer
16 views

Reactive vs MVVM advantages [on hold]

I am in one Swift project that uses MVC. Because of Unit testing i want to add extra modularity using MVVM. After searching for nice design patters, i found (new already something) about the Reactive ...
-1
votes
0answers
24 views

Sorting issue in swift 3

I am trying to sort an array on the basis of timestamp I am getting from a database. But it is not sorting properly according to date. Here is my code: arr = self.newsArr.sorted(by: { $0.newsTimStmp ...
0
votes
1answer
20 views

Change string in other class (without making it global) in swift

I would like to modify a string in another class. This class will then use the variable in a function. Here is what I've tried so far. I always get an error when unwrapping it: fatal error: ...
0
votes
0answers
4 views

Set MPNowPlayingInfoCenter currentTime and songLength from AVAudioPlayer

I'm having trouble setting the currentTime and songLength of the MPNowPlayingInfoCenter. Here's my code: func updateNowPlayingCenter (title: String, artist: String, albumArt: AnyObject, currentTime: ...
0
votes
0answers
7 views

Compiler error: Broken Module / Unable to read diagnostics from file / Function call

I have an obscure error in Xcode, that produces the error message: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 The ...
0
votes
0answers
13 views

Testing: how to deal with a private variable in a class to test?

I'm new to Unit Testing. Simple question about private variables. I have a UIViewController with private var tableView:UITableView I can't access the tableView variable to check the number of rows ...
0
votes
3answers
38 views

Get IndexPath of CollectionViewCell outside of Cell

First of all I am a newbie in swift, so be gentle. I have a problem fetching the indexPath of the cell outside of the cell. I want to get that index path to a function and use it to send the content ...
2
votes
1answer
19 views

Make a unit test wait for a async call inside another method

I'm testing that all my data are correctly loaded in a UIViewController with a UITableView. The code loading the data and populating the table is inside myMethod() and its an an async call. func ...
0
votes
1answer
17 views

Gradient not filling IBDesignable UIView

I'm attempting to add a gradient on an @IBDesignable UIView. All was well in Simulator, but when I run it on a physical device, the gradient doesn't fill the screen. I've got my gradient code in a ...
0
votes
2answers
35 views

lazy properties vs function in Swift 3

struct Person { var personName:String? init(name:String) { personName=name } lazy var greetLazy:String = { return "Hello \(self....
0
votes
2answers
11 views

swift Redundant conformance of 'HomePageVCNEW' to protocol 'UITableViewDelegate'

it is giving an error UITableViewDataSource, UITableViewDelegate Redundant conformance of 'HomePageVCNEW' to protocol 'UITableViewDelegate' import UIKit class HomePageVCNEW: UITableViewController,...
0
votes
1answer
14 views

UIImage not in wanted location of UIImageView

Problem solved, s. comment on first answer... I am using a plugin called Carlos to load images from the cache if they have already been fetched once. However, the images I load only appear in the ...
0
votes
1answer
6 views

Replacing emoji within UILabel with NSTextAttachment - not able to set the plaintext representation back to regular emoji for copying/pasting

I'm replacing emoji within a UILabel/UITextView with my own custom emoji. This works fine, but what I'm struggling with is getting the original emoji to paste. So for example where the UILabel may ...

15 30 50 per page