Swift Programming

Swift is a compiled programming language created for iOS, OS X, watchOS, tvOS and Linux development by Apple Inc. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products. Swift is intended to be more resilient to erroneous code ("safer") than Objective-C and also more concise. It is built with the LLVM compiler framework included in Xcode 6 and later and uses the Objective-C runtime, which allows C, Objective-C, C++ and Swift code to run within a single program. A second free implementation of Swift targets Microsoft's Common Language Infrastructure (a.k.a. .NET) and the Java/Android platform.

Share tech news, updates, or what's on your mind.

Sign up to Post

How to animate tableview row actions when swiped for iOS 10 and below ? . i want to achieve the same  like the iOS  mail app animations bringing one view behind other
0
Cloud Class® Course: Microsoft Exchange Server
LVL 12
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

I need help troubleshooting a firestore query into array.

https://stackoverflow.com/questions/51433177/firestore-query-array
0
I had a problem with UITableView Lagging on Scroll when there were long non-English (Persian) text in the cell (list with more than 40000 items and text with more than 1500 chars wont lag if they are English ) so I came up with this only solution that worked for me to keep the cells in an Array (just the non-English Ones) and reuse them myself instead of dequeuing again (will use normal pattern with other cell types) it works just perfect when the data is already added for the first time , adding a new Data no matter of what type messes up the table. here's the code :

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {


            if(dataIndex[indexPath.row].cell == nil)
            {
                let cell = tableView.dequeueReusableCell(withIdentifier: "ChatRightTextCell", for: indexPath) as! ChatRightTextCell


                cell.configureCell(indexPath: indexPath)
                dataIndex[indexPath.row].cell = cell
                return cell
            }
            else
            {
                let cell = dataIndex[indexPath.row].cell
                cell.configureCell(indexPath: indexPath)
                return cell
            }

        }

note that the Table and the cells are transformed by 180 degree so the cells are stacked from bottom , so adding a new Item to the table be like :

dataIndex.insert(newData,at:0)
tableview.reloadData()


at ViewController start there's a 'for' …
0
We have some IOS app developers who have made a app for IOS (IPA package). They have send the IPA file to me, and they have signed it with their own developer certificate - and say that we must sign it with our own, before we can deploy it.

We are using Intune with SCCM (hybrid) and SCCM I know very well how to deploy and stuff. But do any have some input how we should do this ?. It must be noticed, the App must not be on "app store". It is a local company app that we want to deploy to company phones etc, so outside App store

Can any give some input on this ?

Another note. I tried to put the Ipa on a phone through apple configurator 2. It install, but afterwards the icon stay "grey" - and when trying to click on it, the error comes that the application cannot be installed.  Must the app not work through apple configurationer with manual installation ? - or has this also something to do with the developer signing etc ?
0
Thanks for taking the time to read this. I'm confused on how to insert a comment using the YouTube API. I'm fairly new to using APIs, so I don't quite get what they are saying to do in their documentation.

I've authenticated the user using Google Sign-In for iOS with the scope

    "https://www.googleapis.com/auth/youtube.force-ssl"

Open in new window


which is required to insert a comment. But now, I have to actually insert the comment and (like I've said) I don't understand how to do that. I'm using Alamofire for the request and Swift 4 as my language. I would highly appreciate it if someone could help me.
0
I saved CNContact in the form of vcf in the directory using following code

func generateVCard(for list: [CNContact]) {
        guard let directoryURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first else {
            return
        }

        var filename = NSUUID().uuidString

        // Create a human friendly file name if sharing a single contact.
        if let contact = list.first, list.count == 1 {

            if let fullname = CNContactFormatter().string(from: contact) {
                filename = fullname.components(separatedBy: " ").joined(separator: "")
            }
        }

        let fileURL = directoryURL.appendingPathComponent(filename).appendingPathExtension("vcf")

        let data: Data?
        do {
            data = try CNContactVCardSerialization.data(with: list)
            let documentDirectory = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
            let fileURLInDevice = documentDirectory.appendingPathComponent(filename).appendingPathExtension("vcf")

            do {
                try data?.write(to: fileURL, options: [.atomicWrite]);

                if let cnData = data {
                    //save to directory
                    try cnData.write(to: fileURLInDevice)

Open in new window


then I used the following code the to retrieve it back

let fileManager = FileManager.default
        let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
        let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
        let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
        guard let dirPath = paths.first else {
            return
        }
        let filePath = "\(dirPath)/\(fileName).vcf"
        do {
            let vc = ContactListTableViewController()
            if let data = fileManager.contents(atPath: filePath) {
                vc.contactsList = try CNContactVCardSerialization.contacts(with: data)

Open in new window


in this whole process i loose the imageData of each CNContact
0
While uploading an iOS Application,Xcode Shows Application uploaded Successfully.but it is not Shown in iTunesConnect. Is there any solution?
0
I am a beginner to Xcode and Swift and I am currently creating an application where the user adds a person on the application and after that it right the amount of money they owe that person or that person owes him/her.

Note: I have used core data to store all the value

I have ViewController called PeopleTableViewController where the user adds the name of the person they owe. Then I have PersonDetailTableViewController which shows the list of details the user owes that particular person the selected in PeopleTableViewController. The problem I am facing is that if I add three people in PeopleTableViewController and when I select any one of the people then I am directed to same tableview in PersonDetailTableViewController but I want different tableviews for different person the user selects in PeopleTableViewController.

PersonDetailTableViewController:
import UIKit

class PersonDetailTableViewController: UITableViewController {

    let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext


    var totalLabel: UILabel?
    var person: People?
    var owe: Owe?

    @IBOutlet var personTable: UITableView!

    var dataInfo: [Owe] = []
    var selectedObject: [Owe] = []
    var balanceAmount = "Balance: "

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return (dataInfo.count)
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: 

Open in new window

0
Can someone tell me why, when viewed landscape on a mobile device (iPhone in particular), this page has the ads over the top of part of the results but when viewed portrait (or on a pc) it does not?  http://www.gopherstateevents.com/results/fitness_events/results.asp?event_type=5&event_id=745&race_id=1306

Thank you!
0
If you have a smartphone, I'm sure you've noticed that web applications are changing. Yet, are you aware of how these changes are going to impact your organization or company?
1
Cloud Class® Course: Python 3 Fundamentals
LVL 12
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

I have a web site that I want to convert to an app.  www.etraxc.com and www.my-etraxc.com  How do I go about finding someone who would do that for a reasonable amount and what is the typical cost structure for something like this?
0
I need to integrate Apple Pays decrypted Payment Token Format into a Stripe Rest API call. This does not require any Stripe SDK's or JS files. The raw apple pay token information has already been decrypted ready for stripe to process via 'Source', 'Token', 'Charge' etc. Stripe support will not disclose the solution but acknowledge its possible, why, i am not sure? Spreedly does exactly as i am describing with Stripe, passing in the information below, but how is it correctly structured?

This is the what a decrypted Apple Pay payment token format looks like:

{"applicationPrimaryAccountNumber":"4xxxxxxxxxxxxxxx","applicationExpirationDate":"211130","currencyCode":"840","transactionAmount":1000,"deviceManufacturerIdentifier":"000000000000","paymentDataType":"3DSecure","paymentData":{"onlinePaymentCryptogram":"/random+stuff=","eciIndicator":"7"}}
payment-token-reference.jpg
0
When photo app is opened, I want get event so that I can launch my app. Is there a way to do that?
0
Is it possible to know when other app opens?  I have an app A, and would like to get notified if someone opens other app such as Photo or any other app opens.
0
Supposing I am using an AVPlayer to play a HTTP Live Streaming (HLS) with forced WebVTT subtitle. Is it possible for the app to access the Strings displayed by the AVPlayer and for example print them in the console?
0
I'm trying to use a WebView to open a URL, everything works fine if I use "http://www.ups.com"

If I try use "http://www.ups.com/WebTracking/processInputRequest?tracknum=1Zxxxxxxxxxx"
Then i get "Error 405--Method Not Allowed"

If simply paste the above url into a browser it works just fine.

Why does WebView throw the error?
0
Hi,

I'm currently looking at building a small basic app that a few of my customers are looking for, however they all want it as their own unique app so I will need to whitelabel each release from one core set of code, instead of managing several different sets of code / apps.

All companies will have the exact same app features (which are very basic), however I will need to change the 'logo', 'app name' and 'main UI color' for each release.

Swift / iOS and Android Studio seem to have their own 'Whitelabel Management' feature so that you can have one code base and release variable releases from the code base.

So, you build one core app, and then you can release different builds with the variable settings.

QUESTIONS
01 - Has anyone ever used this approach before, and if so do you have any advice?
02 - Is anyone aware of any software (outside of Swift and Android Studio) that will manage code like this, as I might go the Hybrid approach with React Native.

Thank you in advance for your help.
0
Hi, I have a UIPickerView with 2 images in each row, I would like to animate one of the images when it is selected ...I have been able to animate the whole pickerview when the selection changes (in didSelectRow), but I want to just animate one of the images

with the code below ...in the didSelectRow function how would I reference the selected "firstImage" image to apply the animation?

Instead of memoryPicker.transform I've tried...

pickerView.firstImage.transform -  which gives error: Value of type 'UIPickerView' has no member 'firstImage'
And
view.firstimage.transform -  gives error: Value of type 'UIView' has no member 'firstImage'
Thanks

[code]@IBOutlet weak var memoryPicker: UIPickerView!

func numberOfComponents(in pickerView: UIPickerView) -> Int {
    return 1
}

// The number of rows of data
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {

    return objectsToRemember.count
}

func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
    return 100
}

func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {

    let view = UIView(frame: CGRect(x: 0, y:0, width: 250, height: 100))

    let firstImage = UIImageView()
        firstImage.image = UIImage(named:objectsToRemember[row])
        firstImage.frame = CGRect(x: 0, y: 0, width: 100, height: 100)

    let secondImage = …
0
11
LVL 7

Expert Comment

by:Brian Matis
@Brandon: You're forgetting the market of people that don't want Amazon and Google listening to everything they say all the time :-)
2
LVL 11

Expert Comment

by:Brandon Lyon
Apple does have a slight advantage there with it's anonymous encrypted IDs.

I fully agree with not wanting unknown companies listening all the time. On the spectrum of who is listening when, Microsoft is the worst with Windows 10, Cortana, and being actively hostile towards privacy issues. After that comes Google who does everything mysteriously, doesn't document much of what they do or give you many controls, and has an interest in gathering as much data as possible to sell to advertisers.

On the other hand Amazon Alexa doesn't listen all the time. They have very clear documentation on exactly what they do when and they let you view or delete your complete voice history at any time. Furthermore there is a physical switch to turn the microphones off. They also have a fully open SDK for both hardware and software. Their main interest is getting you to buy stuff, just like Apple.
2
Cloud Class® Course: MCSA MCSE Windows Server 2012
LVL 12
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

This is so cool! I've already gone through some of the sections in Apple's Swift Playgrounds app and loved it, but this new support for programming robotic toys looks even more amazing and fun. Great way to get kids learning programming at an early age. (Ok, who am I kidding... I want this for myself!)

Any of you check out the Swift Playgrounds app or have any of these robots? Are you teaching your kids to program?
8
LVL 5

Expert Comment

by:Juana Villa
That is awesome! I did not know about it. I will definitely learn more about it to show it to my nephews and nieces.
2
I am very new to writing iOS apps - in fact this is the first app I am writing.  In general it is working, but on first load it is very slow to load the data (which is gets from a web service).  I added some timers to sections of the script and believe I have narrowed down the area that is slow.

Briefly the process is:
  1. Get the article data (in JSON) and save it to an Article object and update table cell
  2. For each article check if it has an image, if so access the image JSON to get the URL
  3. Download the image and save to Article Object and update table cell
  4. Display table and use placeholder image if article does not contain an image

It appears to be point 3 that causes the 'freeze'.  In subsequent uses of the app it checks the saved array of Article Objects and loads data from there, and then only adds new / updated articles and deletes old articles and therefore is much quicker.

While it is useable I would like to load the table with the text as soon as it is available and then load images in the background, save it to the object and refresh the cell once it is available.  While there are articles online with code I cannot seem to get them to work.  Either I am left with the app waiting for all the images to load, or just getting the placeholder image for all articles.

My code (for this) is currently in a couple of places.  Loading the JSON is in the TableViewController viewDidLoad() and the image …
0
Hello,
Are there any good products, sites or services that can be used to basically develop a prototype app for planning purposes and relaying information to others like graphics, dev etc.? Something that can be used as a kind of project manager to build a app.

So lets say you have a idea for a app but want to do a rough, not flashy, draft of the layout and mock actions for buttons etc. So if you tap here then this screen pops up type of thing so not actually coding the app but just some type of WYSIWYG interface to help test out the flow of the design before spending time and money on the actual coding and graphics etc.
0
Good morning fellow Apple Geeks!

If you own a first generation Apple Watch, and its battery starts to swell for some reason, Apple has extended out the warranty for you. Despite this being a flaw in the batteries, I get excited when Apple does things like this. To me, it shows the obvious business smarts they have onboard, and that they are willing to do what we call in the military, "the hard right over the easy wrong."

In short, Apple doesn't need to extend the warranty to keep people purchasing their products. However, by doing this they are fortifying the loyalty among their base, and shocking the newcomers who are stepping into the realm of Apple for the first time. That's what happens when you own up to your faults and then try to correct them.

Good on you Apple!
5
LVL 7

Expert Comment

by:Brian Matis
Always nice when a company does the right thing!
1
Hello:

I'm considering taking an online class to learn Swift programming for creating iPhone apps.

But, my laptop has Microsoft Windows 7--not Mac's OCX operating system.

Is it possible to install some sort of "runtime" version of OCX on a Windows laptop?  Also, is it possible to do so without cost?  :)

Thank you!

John
0
Is it possible to send an In-App email from iOS Swift 3 app without it opening a new email message window that the user needs to click 'Send'

I've tried using MessageUI and MFMailComposeViewController but it opens an email message window.

The from and To address will always be the same in my app and I just ned the message to be sent without user intevention
1

Swift Programming

Swift is a compiled programming language created for iOS, OS X, watchOS, tvOS and Linux development by Apple Inc. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products. Swift is intended to be more resilient to erroneous code ("safer") than Objective-C and also more concise. It is built with the LLVM compiler framework included in Xcode 6 and later and uses the Objective-C runtime, which allows C, Objective-C, C++ and Swift code to run within a single program. A second free implementation of Swift targets Microsoft's Common Language Infrastructure (a.k.a. .NET) and the Java/Android platform.

Top Experts In
Swift Programming
<
Monthly
>