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.
2
votes
1answer
27 views
UIFont expansion
I wanted to expand the UIFont class in my application so I could use the large/medium/small letters concept.
I created but for some reason it looks weird. I ...
0
votes
1answer
82 views
Private Swift Function as Objective-C Selector
I want to use a private function on a Swift class as a Selector, say for adding an observer for a NSNotification. Obviously ...
0
votes
0answers
24 views
NSURLSession load images on demand
I'm trying to come up with a system to populate my item images on demand, this is what I have so far. One obvious bug is that an item image could be downloaded multiple time since the ...
1
vote
0answers
24 views
Abstraction of NSNotification that removes the existing observer for a notification when a new observer is added
I ran into a problem in my app where under some conditions, a view controller might be loaded more than once before its deinit (where I was previously removing the observer) is ever called. So the ...
3
votes
1answer
50 views
Model for math facts
I've written a model for an app that generates math facts kids have to solve by evaluating the operation and the difficulty you pass to it at initialization.
I don't like how I am repeating the code ...
2
votes
1answer
68 views
Show and hide views
I have some buttons in my class that show or hide two views (by setting their alpha property to either 0 or 1) when the user taps on them. I have written a function that uses the ...
1
vote
0answers
50 views
Showing Or Hiding AdMob Banners - Purchased vs Not-Purchased IAP Banner Non-Consumable
I have the following code that displays a standard AdMob banner depending on whether the user has purchased an ad-free (banner-free) non-consumable In-App Purchase or not (i.e. If purchased, no ...
1
vote
1answer
108 views
iOS MQTT client app base view controller
I've been working on an iOS IOT client app which uses MQTT.
After some reading I decided to go with CocoaMQTT.
I have only been programming in swift/iOS for about 2 weeks now, so I thought I should ...
6
votes
1answer
234 views
Creating SwiftReachability Class in Swift 2.2
I am novice at creating independent classes for user. I have seen many Reachability library for Swift, but I need to create my own class for that. Here is my code:
...
5
votes
2answers
66 views
Time manipulation for notification reminders
I'm new to programming, Stack Overflow and Code Review. I was encouraged to post this method here based on a question I posted on StackOverflow here. Let me know if you have tips for improving this ...
2
votes
1answer
75 views
Extending UITableViewCell to preserve UIView background color when selecting the cell
When a UITableViewCell has subviews with background color set, when setSelected(_: animated:) gets called, all the views are ...
0
votes
1answer
46 views
Factory pattern for image or shape marker [closed]
I'm making a photo marker application and need to make a factory pattern for marker. I think it is not very flexible and overall not good.
Would you check my code and suggest what could be improved?
...
7
votes
0answers
57 views
Adapting layout for various iPhone and iPad screens using constraints and multipliers
My experience with autolayout tells me that it's very difficult to make app look good on whole variety of devices (from iPhone 4s to 6s especially). Size classes are useful with device position and ...
3
votes
1answer
91 views
Tracking a geolocation
I have created this ViewController using Swift. Its job is to track geolocation and draw a line on a map and save it to core data object. I just want some advice on ...
0
votes
1answer
69 views
Stanford developing calculator iOS app assignment
I'm currently learning Swift by following the Stanford developing iOS app 2015 lecture series. I have completed assignment 1 but am wondering if there is any improvement can be made to my code.
Also, ...
0
votes
4answers
63 views
iOS SDK object to represent a place
I am building an iOS SDK to be consumed by apps. I am building an object that represents a physical place. The interface looks like so:
...
1
vote
1answer
47 views
UICollectionView button target
Within my app i have a UIButton (avatar button which shows a profileVC) within a UICollectionView this button shows up in about ...
5
votes
1answer
70 views
Sorting an array of time-specific tasks of varying importance
RULES:
Strict tasks must occur at the time the user selected no matter what.
Flex tasks are in a priority order. Even if there is a gap big enough to fit several flex tasks with lower priority, no ...
6
votes
1answer
118 views
iOS delegation design pattern
I am working on a project that has a Model-View-Presenter structure and use the delegation design pattern that has the following structure/implementation. I would love feedback.
The ViewController ...
2
votes
2answers
276 views
Music player in Swift
I made a simple mp3 player that plays, pauses and stops a given song, shows the time elapsed, and has a volume control. I read the documentation and can't figure out the difference between the ...
3
votes
1answer
98 views
Using an Edit box in a table views header section to insert the values into the table using swift
Allow me to provide some context. I have a UITableViewCell that contains an EditText and a Button. This cell is then inserted into the self.tableView.tableHeaderView...
4
votes
3answers
111 views
Amanda's Relationship Tips app, with scroll performance issues
I am having some major issues with scrolling in my active app "Amanda's Relationship Tips"
Under the User Advice tab:
I'm using the Parse Database as a backend to pull user data. This lag is ...
4
votes
1answer
81 views
Swift menu code
I want to know what do you think about the structure of this code. If you think that there is some structural improvement to be made, tell me!
Here is a github link: https://github.com/LucianoPolit/...
3
votes
1answer
141 views
NSUser defaults cellForRowAtIndexPath
I have been going back and forth on one certain part of my code. It works, but it doesn't seem right for some reason, as I believe there must be an easier/cleaner way to implement the ...
1
vote
1answer
77 views
Using nested if statements to select textfield for update of associated label
So I have written a very simple program using a cocoa pods library to calculate the distance between different cities. Here is what the UI looks like:
So I have a textfield on top for entry of ...
2
votes
1answer
206 views
Image Scrolling in UITableView with Parse
I'm trying to create an app that is scalable. One of the main features of the app is to view images from a database to a UITableView. Here is my code:
...
3
votes
0answers
462 views
Caching image in memory or on disk
I am caching an image locally..That same image will be used in few screens. Steps for doing this is as follows:
Get image from cache
If not present in NSCache, get image from Cache directory
If not ...
6
votes
3answers
161 views
Loading Configurations from plist into singleton
In my iOS application, I've created a singleton class that reads a configuration plist file and provides accessor methods to easily retrieve the values:
...
6
votes
1answer
492 views
UICollectionView image gallery app
I built an app that allows users to add and remove images in a collection view. I want this to be useful online so I save the images into a database and retrieve them every time. I'm looking for ...
4
votes
1answer
130 views
Optimize Data Sending/Querying to Parse Swift iOS
I have a swift method that I'm using to update Parse in the backend when the button is tapped. Votes are being updated: The method acts as a voting system, incrementing a label every time it's tapped. ...
4
votes
1answer
967 views
Implementing the Hashable Protocol in Swift with the DJB hash function
A while back I made a custom String struct (see github repo) because of the difficulties in dealing with Mongolian Unicode rendering when using Swift String or <...
5
votes
1answer
588 views
Star Rating in Swift
So I needed a a star rating feature to appear in my app - it doesn't need to be interactive.
I have my app connected to a database I've set up in Parse, and I've made a column for OurRatingof type ...
6
votes
1answer
147 views
Ensuring non-expired token before every request
I'm developing an iOS application where data is fetched from a third-party REST API. Each request must contain an authorization token.
In order to implement this, I've written a ...
2
votes
0answers
75 views
Parsing JSON with generics
I get back two dictionaries, I need to parse through them and put in an array two objects. I think I did a very poor job and I have a feeling there is a better way to make the code more compact and ...
1
vote
0answers
370 views
Custom view for data input (in-app (non-system) keyboard)
I have made a custom keyboard that gets loaded from an .xib file.
I decided to go with an in-app only keyboard rather than a system-wide keyboard because the documentation states:
Make sure a ...
5
votes
1answer
54 views
Simple plotting abstract base class and example subclass
I came across a CocoaControl ZFPlot and wanted to extend here. I ended up writing a base class (ZFPlot shown below) as well as several extensions (ZFLine, ZFScatter, ZFBar, none shown here for brevity)...
3
votes
1answer
82 views
Downloading and parsing data
I developed this class to download a JSON from a server, parse the result and call a delegate back on the class that called it. Since I am self started I want to know if this is a good practise.
...
3
votes
0answers
106 views
Algorithm for downloading images
I am working on a product application where user could sell/buy. This application is based on collection view. Collection view has collection cell where it displays product image thumbnail.
The ...
2
votes
0answers
56 views
Quartz2D, circular slider performance optimization
I have a circular slider. Each time i move finger i call [self setNeedDisplay], get new angle to change handle position and mask arc. When i move very fast my CPU load about 70%, it's very hight as ...
5
votes
1answer
81 views
Optimise Code for KukuKube Game
I developed a Kuku Kube game for iOS. Each time I choose a correct different color tile, it will increase a number of tile quantity 2x2 3x3...10x10. How to optimise the code each time the tile ...
5
votes
0answers
58 views
Moves box in direction of touch, and has wraparound when reaching edge of screen
Part of me thinks that it would be simpler to ditch Apple's move API and just updated position with a timer. I know that's what I did with a JS canvas snake game I built a while ago. But I'm also ...
7
votes
2answers
3k views
Background execution in iOS
The following class BackgroundExecutable is to be used to take a function f and return a function ...
1
vote
1answer
162 views
Retrieving creation date from Parse.com data
I got to show the createdAt date in a message timeline, I tried to make a separate array only for dates, but don't know if it is the right path to follow. It seems ...
3
votes
1answer
400 views
Set a font for a UITextView if the font is nil or not equal to desired font
Main question
I am setting a font for a UITextView that is a subview in a custom view. I only set it if the user didn't specify the font size in the Interface Builder.
I have the following working ...
3
votes
1answer
104 views
Switch statement for adding/removing operands to the text part of a label
I have a switch statement with five cases, and four of them are really similar to the others. How could I properly refactor this code to eliminate the duplication of code?
...
4
votes
2answers
1k views
Removing a subview with a subview from a UIView without memory leaks
I made a custom UITextView for vertical Mongolian writing. It is made by subclassing UIView, which has a subview called ...
5
votes
1answer
248 views
Repeatedly check URL for change on iOS
I am wanting to constantly check a URL http://www.example.co.uk/untitled.php which will either return 1 or ...
-1
votes
1answer
221 views
Reading QR Code
What I need to accomplish is matching the QR code to the one I have created. This code works, except it takes at least 30 seconds to verify that it has matched my QR Code. How can I make it faster?
...
4
votes
2answers
919 views
Recursive function to show directions for multiple locations
I have a Mapview which shows a bunch of locations (Events). Here's the code of an Event object.
...
4
votes
1answer
247 views
Using Grand Central Dispatch to fetch data from Parse.com and update UI asynchronously
This works, and the UI is snappy in the simulator, but since this is my first time really using GCD, I'd just like this code to be reviewed before I start using it everywhere. Note that this is ...