Questions tagged [objective-c]

This tag should be used only on questions that are about Objective-C features or depend on code in the language. The tags [cocoa] and [cocoa-touch] should be used to ask about Apple's frameworks or classes. Use the related tags [ios] and [osx] for issues specific to those platforms.

Filter by
Sorted by
Tagged with
1
vote
0answers
19 views

State machine to handle sequential and async events

I created this state machine to handle events. I'm unsure about my implementation firstly because I don't use a transition table or anything like that, instead, I ...
2
votes
1answer
32 views

iOS Attributes in the data model

I am working on a product-related app where the data model for a product attribute feels too heavy. But I can't split it into several small data models because they are all about goods. At present, ...
4
votes
2answers
85 views

SIMD Mandelbrot calculation

I was messing around with GPU compute shaders the other day and created a Mandelbrot shader. Unfortunately, Metal doesn't support double-precision in compute shaders, so beyond a certain zoom level, I ...
-2
votes
1answer
42 views

3D vectors in Objective C

I am trying to learn Objective C and want to make sure I am following the proper practices/convention. I would very much appreciate advice on what to change/improve I also have some questions: when ...
4
votes
2answers
127 views

Translating Objective-C use of static and +(void)initialize to Swift

I am converting an old Objective-C class into Swift. My actual question is at the very end after all of the code. Here is a cut-down version of the Objective-C class: DateInfo.h: ...
5
votes
1answer
406 views

Point distance program written without a framework

I have been developing a cross-platform game based on open C libraries (mainly glfw) with a direct focus on Windows development. The beginning of my programming career taught me familiarity in ...
2
votes
1answer
44 views

Checking user verification status

The User story is as follows: Users are allowed to get "verified", so other users know they have passed a background check. After tapping "get verified" button, or the "verification badge" ...
1
vote
0answers
45 views

UICollectionViewCell's content layout misbehaves when UICollectionView scrolls to the top of the screen

UICollectionViewCell's content misbehaves , the layout animates, when UICollectionView scrolls to the top of the screen. I am asking here, because it looks like an apple's bug. looks like squeezed ...
4
votes
1answer
42 views

Creating directory within Application Support, and preventing iCloud backup

I'm using react native to build an iOS app, but have little to no experience in obj C or iOS development. The app I'm building has a bunch of content files that aren't user specific, will be ...
0
votes
2answers
262 views

Multiple AFNetworking calls In a view controller

Multiple AFNetworking calls In a view controller. The code is very wield. I think , to negotiate with the server , and combine those into one url, instead of many urls. ...
0
votes
1answer
121 views

Objective-C and AFNetworking

This is Objective-C and about Networking Request. Just set the AFNetWorking Manager and get method name from the method lists below (it is all Post request). The way we take now is quite weird. If ...
0
votes
2answers
219 views

Sychronous wrapper around UIApplication.openURL:options:completion:

I am deprecating iOS 9 on a project. One of the differences in the framework is that the openURL method has changed. iOS 9 - (BOOL)openURL:(NSURL *)url; iOS 10 ...
0
votes
2answers
143 views

Optimizing UITableViewCell with singleton property

In UITableViewCell class, I have two properties: UINavigationController ...
3
votes
2answers
296 views

A C++ wrapper for Apple CoreFoundation

The wrapper makes it easy to manage memory when using CoreFoundation objects. It aims to act like a simple shared_ptr. Here is a usage example: ...
-1
votes
2answers
107 views

Up/down arrow key commands

There are sources with these rules. I've listed the source too much, but I want to make it shorter and easier. ...
2
votes
1answer
219 views

Objective C implementation of Swift's if-let

This [Objective-]C-preprocessor macro currently handles single-variable if-let-not-nil and if-let-is-type, but doesn't handle multiple simultaneous tests and doesn't handle ...
2
votes
1answer
1k views

Populate TableView with JSON data

I basically want to display JSON data in a TableView. The TableView always displays a List ...
6
votes
0answers
2k views

Iterate through all the photo library in iOS

This function is supposed to return a map of all unique local identifiers of images that are on the iPhone using the IOS Photos Framework. (it is a map so nSnull or (any object can be mapped to it) ...
6
votes
2answers
58 views

Checking for many alertable conditions before saving customer information

What's the best way to refactor this code? The method does a lot of checking before showing an alert. And the method is too long for my taste. I'm thinking of extracting the checkers into their own ...
13
votes
1answer
976 views

Interview coding challenge for iOS Part 2 - the application in Objective-C and Swift

I recently interviewed with a company that needed a C/C++ programmer to work on the iOS side of the products. The job description indicated they needed someone with 4 years of Objective-C and iOS ...
5
votes
1answer
751 views

Interview Coding Challeng for iOS Part 1 - the Static Objective-C Library

I recently interviewed with a company that needed a C/C++ programmer to work on the iOS side of the products. The job description indicated they needed someone with 4 years of Objective-C and iOS ...
1
vote
1answer
276 views

Populating a UITableView with staff members using Firebase data

The end user will be able to see a list of staff that works at a church. The staff consists of 5 individuals with 5 different position titles (Minister, Pastor, etc.). This data is pulled from ...
2
votes
0answers
167 views

Throttling several HTTP parallell requests

I'm using the above piece of code to do some HTTP calls in parallel. This loop is running inside a NSOperation. I must throttle a bit the requests (so I don't overload the server). The code is working ...
1
vote
0answers
49 views

Create a new event and view its details

I have A page, where you can create an event using the name, location, enddate startend date, attendee, URL location, repeat options, alert options and etc. There is two scenario when the user can ...
2
votes
1answer
135 views

CommandLine StreamFormatTester

Using Chris Adamson's book Learning Core Audio I'm getting familiar with Core Audio for Mac/iOS. The code examples are 100% Objective-C. I'm trying to follow along using Swift 3. This small piece of ...
1
vote
2answers
2k views

Checking that a 6-digit number is not repeated and not in sequence

Following is the objective C code snippet to check that the 6-digit number is not repeated and not in sequence/reverse-sequence. I have just printed the proper messages in ...
1
vote
0answers
603 views

Mocking protocol with class/static functions in Swift

I am using one of the open-source Objective-C keychain wrappers to store data in iOS keychain. For test cases, I have created protocol as: ...
-1
votes
2answers
250 views

Initializing a big static array for a card-based iOS app

I have a card-based iOS app that uses a sizable static array of cards. Each card has several properties, mostly strings, numbers and boolean. The first version of this app had 3-4 properties. The ...
3
votes
2answers
95 views

Create a stack implementation that handles the multi thread scenario

MyStack.h @interface MyStack : NSObject - (id)pop; - (void)pushObject:(id)object; @end MyStack.m ...
1
vote
1answer
884 views

Controlling Drone with iOS Speech Recognition

I got a Parrot Mambo which comes with an SDK for creating your own app for controlling it. I decided to use the iOS Speech Recognition library so I could use basic voice commands to control it. The ...
1
vote
0answers
54 views

Block breaking with paddle/ball iOS Game

I created an iOS app that recreates the "ball breaking" game where a paddle is used to deflect the ball to break blocks. The main purpose is to get familiar with UI concepts since I have primarily ...
4
votes
1answer
2k views

Check for iOS version

Here's an approach i came up with for checking IOS versions. ...
1
vote
1answer
77 views

Hard-coded iOS keyboard [closed]

I am starting to write code for a keyboard in iOS. It's pretty much hard-coded and I need suggestions on how I can make it more professional style and more efficient. ...
1
vote
1answer
1k views

Using a webservice with blocks and returning data via callback

I load some data from from my webservice via a method using blocks and callbacks. From my ViewController I make a request to the data loading class and pass the ...
3
votes
1answer
275 views

Storing global constants in app delegate or singleton

I am converting a non ARC projecs to ARC. I just found that after login in my old app, the data is stored in app delegate objects, like Home_DataArray, various ...
1
vote
0answers
89 views

Functional-style Cocoa XML serializer and object mapper

I'm working on an XML-to-model-object serialization and deserialization library. There are three main design goals for the code: It should parse XML into and serialize from Cocoa-native collection ...
0
votes
2answers
619 views

Convert NSInteger into NSString

This is my sample code to convert a integer into string. Is it very costly to do the multiple loops of [NSMutableString stringWithFormat:..]? I.e should I just use appendString and get the NSString ...
3
votes
0answers
112 views

Sesame Street project

I started a tutorial online to get a little bit more knowledge about views. But after I did the basic I decided to finish the game. The game is a little "I spy" game where the user tries to guess the ...
2
votes
2answers
83 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 ...
1
vote
1answer
51 views

Sorting Timestamped Messages (iOS)

An app I'm building professionally includes rudimentary text messaging. It allows users to send from the phone, and it polls for new messages (I know, yikes. Push notifications are a future task) with ...
4
votes
1answer
1k 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 ...
6
votes
3answers
1k views

Bubble Sort in Objective-C

Following is Objective-C method implementation I did for one of the most simplest sorting algorithms, Bubble Sort to sort an array of integers. Note:- I have defined it as a static method in the ...
2
votes
2answers
2k views

UIButton Subclass - Overriding getters to return placeholder/default values

I'm in the process of converting a custom UIButton from Objective-C to Swift which has custom properties and default values for those properties: MyButton.h ...
1
vote
0answers
73 views

Checking whether a directed graph contains a cycle

I create a myGraph class as shown below. Then I created an instance of the graph by giving the adjacency list as a NSDictionary and then call the isGraphCycleFree method. Will this answer look good ...
2
votes
2answers
159 views

Method to check if TicTacToe board has a winner

I have a class called TicTacToeBoard that has a [3][3] array of TicTacToeBoardCells. Doc neck if board has a winner, I check if ...
4
votes
2answers
85 views

Given a set of random strings, write a function that returns a set that groups all the anagrams together in objective-c

I would like to get feedback on the solution and a question regarding Big O. I am first converting each character in the string into the array and that would be O(n) then i am sorting the array O(n ...
2
votes
2answers
840 views

Current user as a class-level property in Objective-C and Swift

I was recently tasked with architecting a user/profile object in Objective-C and wanted the ability to access a static instance from the class level, similar in style to the way Parse manages their ...
2
votes
1answer
1k views

Implementing a HashTable in Objective-C

I am trying to implement a hash table in Objective-C. I did some testing and the implementation seems to work. I am using an NSMutableArray to store linked lists ...
4
votes
0answers
310 views

Unit Testing Against Exceptions

I am writing a Swift library. I'm writing unit tests for that library. I am afraid that some of the code that I am testing will possibly throw exceptions. In Swift, we can handle errors, but we can ...
1
vote
0answers
41 views

Create or update a row in a queue with the given new item

This works just as documented, but the code doesn't make it very clear that it does: ...