iOS is an operating system for mobile devices developed by Apple Inc. that is currently used in their iPhone, iPod touch, iPad, and Apple TV (2nd generation) devices. It shares a lot with Mac OS X, but is optimized for touch-based interfaces. Use this tag for questions about iOS-specific code.
6
votes
1answer
33 views
Draw editable angles
One of the first things I did when I learned Objective-C was to create a little canvas with editable angles. Basically, you tap to create points. Every tap connects to the previous tap. So if you tap ...
5
votes
1answer
41 views
Multiple Choice Guessing Game
I've built an app for members of an organization I'm in--the app shows the picture of a member with four multiple choice buttons, and the user then tries to guess the member's name. Pretty simple, ...
10
votes
1answer
70 views
Finger painting code
I have a very simple view that handles touch events and draws accordingly. It's nothing significant, but it does use a bit more CPU than I would like (35%). Again, it is the bare minimum (<90 ...
4
votes
1answer
39 views
Imitate UITableView reordering interaction
I have a UIScrollView full of vertically stacked subviews which I want the user to rearrange as they desire. I've implemented a ...
-1
votes
1answer
28 views
Globally accessible helper class [closed]
I would like to get opinion if I am doing this right. I am creating a helper class that is globally accessible to my whole project. I want it to be easily called like ...
3
votes
1answer
44 views
Managing a wish list from an API
I have a class that I use to manage a list to/from an API in Swift. Using a clean code approach, I'm wondering if, how, and why I should change it when I have a class that uses it for just one or two ...
11
votes
1answer
82 views
Top wiki pages as an app
I recently did an interview task. I was rejected because of bad code quality. There was two tasks. Here I will present the first, second will be posted in time.
This project is avalible on GitHub
...
3
votes
1answer
116 views
Show a quiz from JSON in iOS
I have to create a quiz of showing questions from a JSON and post back the answers.
Here's the structure of JSON:
...
8
votes
1answer
228 views
First assignment for Stanford iOS8 Course: enhancing a calculator
I recently started learning Swift through Stanford iOS8 Course. The first assignment is to add some features to simple Calculator which was presented during lectures.
List of tasks:
add button for ...
6
votes
1answer
66 views
Checking two text field for match and checking for null
Is this the most efficient way to do this? Any suggestions on some thing I might have missed or can do better?
...
7
votes
1answer
54 views
Comparing 2 arrays of dictionaries and saving user preferences
I will start by explaining the situation and then show some code. I have an app that has an array of "default" settings to display on a user's dashboard. The user can modify these settings to enable ...
2
votes
1answer
72 views
Determining the number of days from today
Today I've got a pretty simple snippet to be reviewed. The function is extremely simple, as all it does is retrieve some entities from Core Data and then compares the ...
2
votes
1answer
79 views
Idiomatic way of handling optional values in Swift
I'm new to iOS development and also Swift. I'm working on a project consisting of a menu that leads to my various experimentations with the iOS SDK.
I've written the menu titles and ...
5
votes
2answers
143 views
Registering a plist to NSUserDefaults
I've been struggling with registering a plist into NSUserDefaults and I've finally got it working, though I'm not sure that its written properly. I'm hoping someone ...
6
votes
2answers
152 views
Simple 3…2…1 countdown in iOS app
I would like to display a 3...2...1 countdown on my iOS app (before to take a picture) but I didn't find an elegant solution. I don't want to make a Countdown app with an NSTimer. For me the important ...
8
votes
3answers
2k views
Swift iOS - Call back functions
I'm working on an iOS app which handles API request based on authentication. Authentication is done through OAuth and every API request is sent along with ...
3
votes
1answer
90 views
1
vote
1answer
44 views
Push Notifications - save token id into a database using Asynchronous Request
based on this answer I modified my code. Is this the correct approach now?
...
3
votes
1answer
424 views
Save token id into a database in Swift
I want to save my users tokens id into my database using POST request in Swift (here PHP code here). I am a bit confused about synchronous and asynchronous request.
Is this code the right way to do ...
2
votes
1answer
148 views
BaseTableViewController with pull to refresh and auto load more
I've implemented a table view controller for the purposes of subclassing. The table view controller implements a pull-to-refresh which will automatically reload the table view's data. I am looking ...
5
votes
1answer
170 views
Avoiding callback chaining in authenticator
I'm developing an iOS Application in Swift that uses Google Cloud Endpoints as its backend. For now, I've just written the code for the user to login with his Gmail account and I've refactored it as ...
0
votes
0answers
107 views
Unit testing - Parsing data from the Weather Underground API
I'm writing unit tests for the first time.
The tests are for my library on Github.
I downloaded the JSON and stored it into a local file that looks like this:
...
2
votes
2answers
217 views
Creating an iOS form with many similar text field cells
I'm using multiple instances of an object creating a form:
...
6
votes
2answers
305 views
Clear function for Stanford iOS 8 Calculator application
I am following the Stanford iOS 8 lectures and I believe I have successfully added the "Clear" functionality to the application, but I don't know if I am doing it properly.
Controller
...
3
votes
1answer
98 views
Deleting email using mailcore with imapSession
The following function works fine. However, deleting 1 mail takes about 4 seconds (from start of operation to the firing of the completion handler).
Currently, using ...
3
votes
1answer
137 views
Retrieving values from UITableViewCell
I have a UITableview with custom cells, every cell has a button called cellButton. When the user taps the button I present an ...
1
vote
0answers
29 views
Create a new window in Titanium
I'm trying to define a new window for use inside a Classic Titanium application for iOS. For the window to work properly, some preprocessing is required. This preprocessing includes the creation of ...
7
votes
1answer
150 views
Localization manager based on ReactiveCocoa
I have a localization manager class which can change app language on the fly. It's using ReactiveCocoa and my main concern is that I'm not using some of RAC parts correctly.
First (in ...
5
votes
1answer
111 views
Creating and saving blurred screenshots in iOS
I am trying to create a class that takes a screenshot of the screen, makes it blurry and saves it to NSUserDefaults.
...
1
vote
1answer
55 views
Preparing a walkthrough: Freeze effect :s
I have a method that load my walkthrough view. I have my view controller composed of a scroll view. And others views controllers used only for the walkthrough (maybe I should used xib uiview instead ...
5
votes
1answer
274 views
Caching data on disk in iOS
I've got an app that's got an activity/timeline like view. Since I don't want to retrieve the entire timeline every time, I'm caching all the events.
Currently, this is how I go about it:
...
6
votes
1answer
225 views
-3
votes
1answer
62 views
Handling button behaviour [closed]
I have an iOS app where I use some buttons for different things, but I'm repeating a lot.
For buttons pressed:
...
16
votes
4answers
8k views
Swift 1.2 Singleton Implementation
I am pretty new to Swift, as a solo developer I was wondering if somebody could pass comments on the singleton implementation below. The code does work, but being new to Swift and knowing that there ...
11
votes
2answers
603 views
Simple LibGDX Pong game
I created my first java game in LibGDX and it's working fine but I'm 100% sure a lot of my code can be written shorter than now. Does anyone have tips how I can make this code better?
Like the ...
11
votes
2answers
2k views
Getting WiFi SSID on iOS in Swift
I've seen a lot of Objective-C implementations but I'd like to do it in Swift.
I did it like this and it seems to work just fine. Does anyone have comments and/or improvements to make?
...
10
votes
1answer
318 views
Changing image of a UIImageView based on a scrollView contentOffset
My task is pretty simple and my code works, it's just that my code feels a bit clumsy to me (and probably will for you too).
I have a view controller (...
5
votes
1answer
153 views
Parsing travel duration data
I'm trying to parse an estimated travel duration and distance between two waypoints using Google Directions API. Tap on this to see an example of data received.
...
3
votes
1answer
528 views
Using NSPredicate with NSFetchRequest in a NSFetchedResultsController
I am learning CoreData and I wanted to have my code reviewed. As usual, I get something to work, then I attempt to refine it.
I have a data model that consists of an Item entity and a subItem entity. ...
3
votes
1answer
93 views
HMSegmentedControl react to tapping on currently selected segment
I'm using HMSegmentedControl, an open-source UISegmentedControl subclass. I'm trying to react to the user tapping on the currently selected segment. HMSegmentedControl only supports reacting to a ...
8
votes
1answer
251 views
Networking in iOS Swift
This piece of code is working - It gives me a lot of JSON back, which I have yet to parse, but I'd like to show my code here first to get tips on how to improve what I already have:
...
4
votes
0answers
141 views
Switching between view controllers that are loaded in the background
I have a dining menu app that scrapes the data from a website and redisplays it in a mobile format, displayed below:
If the user swipes left and right, the app will show the previous/next meal (ex. ...
6
votes
2answers
774 views
Segue between view controllers using NIB files
I'm learning how to develop for iOS and I want to begin with nib's before storyboard to get a better understanding.
I just set up 3 view controllers:
...
5
votes
1answer
448 views
Closure as UIControlEvents handler
I'm expanding the functionality of this SO answer.
Mainly I'm focusing on:
You can add as many handlers as you want.
You can remove (i.e. cancel) the handler.
You can receive the ...
1
vote
2answers
78 views
Archiving data in file system for iOS
Being my first time archiving data to the file system, I would like to have my code reviewed. This simple test project works as expected, but I want to see if what I am doing is following best ...
6
votes
1answer
4k views
Pure Swift solution for socket programming
I have spend quite some time now to find out how exactly to do socket programming in Swift (Xcode 6.1). There are a few examples out there, but most of them no longer work for the latest release of ...
2
votes
0answers
130 views
Usage of MVVM in iOS [closed]
I'm an iOS developer and I'm guilty of having Massive View Controllers in my projects so I've been searching for a better way to structure my projects and came across the MVVM (Model-View-ViewModel) ...
2
votes
1answer
919 views
Subclass SKSpriteNode
I decided to subclass SKSpriteNode for a game test in Swift today and soon realised that it was not as simple as my Objective-C background suggested. After a little ...
4
votes
2answers
129 views
NSAssert or NSLog in defaults switch case
I am wondering if I should use NSLog(@"Switch out of range") or NSAssert(FALSE,@"Switch out of range"); in the following ...
5
votes
2answers
74 views
Consecutive animations
I'm new to Core Animations, I want to fade out two different layers one after another.I write them in a CATransaction block. I wonder if there is better approach to make such animations.
...