[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

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

Hello, I am developing a type of "note taking" App in iOS for a specific vertical market (its not just a simple note taking App, but note taking is a basic function of the App). A user will use the App to collect data (text and images) and store them in permanent storage (a data file of some sort.)

The iOS App will have a companion desktop application for the Mac, which will take the data in the "data file" collected by the iOS App and perform more analytical processes. So, the system is a two part system. One part is the iOS App. portion (the data collection part) and the second portion is the Mac desktop application part to perform more in-depth analytical functions.

It kind of looks like this  ---   iOS App >>>> (data file) <<<< Mac Application.  [The "data file can be XML, a database, etc.]

*** My question is:   How can I share the "data file" between the iOS device and the Mac portion of the system. By "share" I mean, how do I collect the data on the iOS App, put it into a permanent storage file and then send that file to the custom Mac desktop application?

Note: I am not asking how to share unassociated files between devices.

Also, if anyone has an example of how to create Apps with data storage, for use in CocoaTouch Mac applications, I would greatly appreciate it. I have not found any tutorials that show how this is done in a practical manner.

Thank you for your help.
Fulano
0
Exploring SQL Server 2016: Fundamentals
LVL 12
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

I am looking for someone to develop an app (iPhone first, then Android) from a website (http://www.etraxc.com).  Any idea where I should start looking?
0
IOS project using swift
On my story board I have a launch screen that is the entry point. Now I want another view controller, I drag a view controller onto the storyboard. I create a cocoa touch class that is a subclass of UIViewController, naming it DTViewController. On storyboard, I select my new view using the left most icon on the top of the view and go to custom class. I select DTViewController as my custom class.  To stop warnings about my view being unreachable I check "Use StoryboardID" and enter MyDeskTop as the Storyboard ID. I drag a label onto the new view.

I have the following code in AppController.swift
private func handleAppState(){
if let user = Aut.auth().currentUser{
let vc = DTViewController()
rootViewController = NavigationController(vc)
} else {
rootViewController = LoginViewController()
}
}

Open in new window


When I run the app the splash screen appears and then the DTViewController appears. The problem is it's not picking up on the View in the Storyboard, just the DTViewController class. My evidence is the label doesn't show up but if I change the background color in code in DTViewController the change shows.

What am I doing wrong?
Thanks!
0
I have a UIPageViewController which I am using for onboarding/walthrough screens but at the moment they only work with swipes. I added a button but I can't actually connect it and create an IBAction. I was able to programatically create a button that could print to console but I don't know how to get it to move the screens like swiping does.

class PageViewController: UIPageViewController, UIPageViewControllerDelegate, UIPageViewControllerDataSource {
    
    
    
    var pageControl = UIPageControl()
    
    // MARK: UIPageViewControllerDataSource
    
    
    
    lazy var orderedViewControllers: [UIViewController] = {
        return [self.newVc(viewController: "sbBlue"),
                self.newVc(viewController: "sbRed")]
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.dataSource = self
        self.delegate = self
        
        
        
        // This sets up the first view that will show up on our page control
        if let firstViewController = orderedViewControllers.first {
            setViewControllers([firstViewController],
                               direction: .forward,
                               animated: true,
                               completion: nil)
        }
        
        configurePageControl()
        
        // Do any additional setup after loading the view.
    }
    
    func configurePageControl() {
        // The total number of pages that are available is based on how many 

Open in new window

0
Hello EE,

in XCode 10 with Swift, I have successfully added Firebase database and my Sign up and Login works well.
I was wondering if in some ways, mayeb in AppDelegate? .. I could add some code that would signOut the user after x minutes of inactivity and go back to first screen .. ?
0
I am very new to Swift so please forgive me if I get some terminology incorrect etc.

I have created a todo list which first lets you add a category and then you can tap into the category and add items to the category. I am using Realm as the database.

I am able to delete individual items and individual categories, but when I delete a category and there are list items still in that category, I want it to also delete the items associated with that category.

This is to delete an individual item:

        if let item = todoItems?[indexPath.row] {
            do {
            try realm.write {
                realm.delete(item)
            }
            } catch {
                
                print("error deleting item, \(error)")
            }
        }

Open in new window


And this is to delete a category:

 
       if let categoryForDeletion = self.categories?[indexPath.row] {
            
            do {
                try self.realm.write {
                    self.realm.delete(categoryForDeletion)
                    
                }

            } catch {

                print("Error deleting, \(error)")
            }
        }

Open in new window

0
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
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
OWASP: Threats Fundamentals
LVL 12
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

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
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
Build an E-Commerce Site with Angular 5
LVL 12
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

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 12

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

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
>