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

I need some help understanding swift/xcode positioning of elements. I've done several tutorials and built some apps but I really don't get it. I know my way around the xcode IDE, for instance the pin tool for creating constraints.

If I have 3 buttons on the left side of a view, one 15% from the top, one in the middle, and one 15% from the bottom. For the sake of discussion, I'll use my top edge on the top one and bottom edge on the bottom button.

How do I maintain this across different phone sizes? In this case portrait only. I can pin the top and bottom and then pin the center button to it's upper and lower neighbors but that fixes them in place. And they would be different percentages of distance apart on different size phones.

What am I missing?

Thank you!
0
OWASP Proactive Controls
LVL 13
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

can you configure a real switch with packet tracer?
0
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
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 app in swift
Single view controller with a table view. Project runs as it's supposed to. My question is: How do I move my table view down the page a bit so I can add some text above the table view? I think the answer is in this extension class so I'll post that first. Thanks!

Extension.swift
import UIKit

extension UIView {
    
    func anchor (top: NSLayoutYAxisAnchor?, left: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, right: NSLayoutXAxisAnchor?,  paddingTop: CGFloat, paddingLeft: CGFloat, paddingBottom: CGFloat, paddingRight: CGFloat, width: CGFloat, height: CGFloat, enableInsets: Bool) {
        var topInset =  CGFloat(0)
        var bottomInset = CGFloat(0)
        
        if #available(iOS 11, *), enableInsets {
            let insets = self.safeAreaInsets
            topInset = insets.top
            bottomInset = insets.bottom
            
            print("Top: \(topInset)")
            print("bottom: \(bottomInset)")
        }
        
        translatesAutoresizingMaskIntoConstraints = false
        
        if let top = top {
           self.topAnchor.constraint(equalTo: top, constant: paddingTop+topInset).isActive = true
        }
        if let left = left {
            self.leftAnchor.constraint(equalTo: left, constant: paddingLeft).isActive = true
        }
        if let right = right {
            rightAnchor.constraint(equalTo: right, constant: -paddingRight).isActive = true
        }
        if let bottom = bottom {
       

Open in new window

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
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
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
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
Exploring ASP.NET Core: Fundamentals
LVL 13
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

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
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
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
Is there a way to do Xcode development and maintain the projects in such a way that if I have to switch between 2 - 3 macs I still have access to my projects.  Right now doing a course on Swift and that would be helpful

Thanks
0
Hi all,

I'm new to both VS and Cordova so be gentle :)
I'm trying to lock my cordova app into landscape orientation only. I went into the config.xml and set orientation to Landscape which ends up doing this:
<preference name="Orientation" value="landscape" />

Open in new window

But when i run/debug the project in browser emulator, the device is still portrait.
I tried using net.yoik.cordova.plugins.screenorientation plugin with following code nad it didn't work either (alert worked)
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    window.screen.lockOrientation("landscape");
    alert("123");
}

Open in new window

Can anyone please point me in the right direction on how to lock entire app into landscape permanently. Google has not helped me.
Thanks,
Primoz
0
Is Windows Xamarin the next great tool for Cross platform mobile development? What are the alternative tools available and their advantages?

Is jquery mobile another great tool for Cross platform mobile development?
http://jquerymobile.com/
0
C++ 11 Fundamentals
LVL 13
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

What's the requirements to develop current latest Apple App?

Can you provide details in terms of recommended Models, OS versions, Development tools, etc?

I need to draft a spec to purchase one for office use.
0
Hello:

Although I have many skills outlined on my resume, I want to add another practical skill, in case my current skills become obsolete.

So, I have been toying with the idea of teaching myself Swift or some other iOS programming language in order to be able to create apps for the iPhone.

Out of the many new business skills a professional could learn, would this be the best?  

If so, how long does it take to learn and is it extraordinarily difficult?  Are there are good and free tutorials online that will successfully teach the lay person such a programming language?

Thanks!

John
0
I am a rookie with programming but wanted to delve into programming for Androids.  What language should i use?  or what development program.?  also, does this language translate to coding pretty well if i wanted to create the same app for ios.
any commentary would be greatly appreciated
0
As all "great" projects start, my wife asked me to build an app for their small teacher organisation. I'm new to development of IOS, but have worked in java, so I've made progress in getting up to speed with Swift and building up the framework of the app and getting it operational.

However, it dawned on me that I don't have an understanding of do's and don'ts when building a secure app. The books I've read focused on the UI more than the data itself. With the current project, I don't have risk that I need to worry about. But would like to use this app as a ginnie pig.  I'd like to know what are things I should be doing or adding into a iOS app to ensure it's secure and protected. I am not asking from a UI Pov (Apples KB documents provided me with that), but more on the lines of protecting the data if I was sending secure data from the app to a cloud DB (I.e. Firebase) or storing user profile or credentials in the apple "Core Data".
0
Hi

I received a $0.99 bill for iCloud today. I was infuriated! I got it for me and my mom's massive web-space needs

Nah, I just need to know how to turn billing off. It wasn't in App Store. ?

Thanks
0
I have a swift 3 app that uses Alamofire to connect to a web service and get data.  All working but once I am done with the data (inserted into Core Data) and exit the Alamofire closure, the memory held by the variable holding the data is not released.  See code below:  The json variable below will hold to 25MB of memory.  The JSON type is Freddy JSON.  How do i identify why this memory is not being released

            Alamofire.request("\(URLServer().ipUrl)\(urlMethodWithParameters!)") .responseJSON  {
                (response) -> Void in
                
                if response.result.isSuccess {
                    do{
                        let json =  try JSON(data: response.data!)
                        
                        print("JSON retrieval success!")
                        self.processCustomerSyncData(json)
                        CustomersAssociationsSync().performCustomerAssociationsDataSync()
                    }catch{
                        print("error")
                        let netWorkError = AppDelegate.sharedInstance().progressViewController
                        SyncherBase.synchError(sender: netWorkError!)
                    }
                }else if response.result.isFailure {
                    print("User authentication failed!")
                    let netWorkError = AppDelegate.sharedInstance().progressViewController
                    SyncherBase.synchError(sender: netWorkError!)
                }
                
 

Open in new window

0

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
>