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
2 votes
2 answers
95 views

Replace Western Arabic numerals with Persian digits

I've written and used this code in my apps whenever needed to convert any Western Arabic numerals into Eastern Arabic (or better say, Persian/Farsi) numerals in any Persian text. It works fine as ...
user avatar
  • 121
1 vote
3 answers
58 views

How to use string constants correctly

I often get into the dilemma of how to use string constants, this is the way I use now: ...
user avatar
  • 133
4 votes
1 answer
309 views

Objective C String to JSON formatting

Quick disclaimer. I've programmed Java for years but this is the first Objective C I've ever written. I've written some code which almost unfortunately works but frankly hurts my eyes with the number ...
user avatar
2 votes
2 answers
143 views

Convert C to Swift

I trying to convert this C code for calculating distance from RSSI to Swift code. I try to do it by myself, but considering I'm beginner, I need help in how to do it. Here is C code: ...
user avatar
  • 23
2 votes
1 answer
51 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, ...
user avatar
  • 133
4 votes
2 answers
312 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 ...
user avatar
  • 11.5k
-2 votes
1 answer
122 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 ...
user avatar
  • 13
4 votes
2 answers
541 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: ...
user avatar
  • 195
5 votes
1 answer
420 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 ...
user avatar
2 votes
1 answer
51 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" ...
user avatar
1 vote
0 answers
136 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 ...
user avatar
  • 391
5 votes
1 answer
509 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 ...
user avatar
  • 51
0 votes
2 answers
556 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. ...
user avatar
  • 391
0 votes
1 answer
180 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 ...
user avatar
  • 391
0 votes
2 answers
464 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 ...
user avatar
  • 101
0 votes
2 answers
217 views

Optimizing UITableViewCell with singleton property

In UITableViewCell class, I have two properties: UINavigationController ...
user avatar
  • 391
3 votes
2 answers
553 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: ...
user avatar
  • 133
-1 votes
2 answers
115 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. ...
user avatar
2 votes
1 answer
485 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 ...
user avatar
  • 121
2 votes
1 answer
2k views

Populate TableView with JSON data

I basically want to display JSON data in a TableView. The TableView always displays a List ...
user avatar
6 votes
0 answers
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) ...
user avatar
6 votes
2 answers
59 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 ...
user avatar
13 votes
1 answer
1k 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 ...
user avatar
  • 18.2k
5 votes
1 answer
836 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 ...
user avatar
  • 18.2k
3 votes
1 answer
372 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 ...
user avatar
2 votes
0 answers
204 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 ...
user avatar
  • 121
1 vote
0 answers
52 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 ...
user avatar
2 votes
1 answer
171 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 ...
user avatar
1 vote
2 answers
3k 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 ...
user avatar
1 vote
0 answers
719 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: ...
user avatar
-1 votes
2 answers
284 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 ...
user avatar
3 votes
2 answers
104 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 ...
user avatar
1 vote
1 answer
941 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 ...
user avatar
  • 113
1 vote
0 answers
63 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 ...
user avatar
4 votes
1 answer
2k views

Check for iOS version

Here's an approach i came up with for checking IOS versions. ...
user avatar
  • 141
1 vote
1 answer
84 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. ...
user avatar
1 vote
1 answer
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 ...
user avatar
  • 63
3 votes
1 answer
469 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 ...
user avatar
  • 183
1 vote
0 answers
103 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 ...
user avatar
  • 115
0 votes
2 answers
1k 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 ...
user avatar
3 votes
0 answers
115 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 ...
user avatar
2 votes
2 answers
87 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 ...
user avatar
1 vote
1 answer
55 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 ...
user avatar
  • 113
4 votes
1 answer
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 ...
user avatar
  • 221
6 votes
3 answers
2k 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 ...
user avatar
3 votes
2 answers
3k 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 ...
user avatar
  • 571
1 vote
0 answers
76 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 ...
user avatar
2 votes
2 answers
245 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 ...
user avatar
4 votes
2 answers
93 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 ...
user avatar
  • 673
2 votes
2 answers
1k 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 ...
user avatar
  • 571

1
2 3 4 5
8