As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [ios]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

Good way to coding on React-Native?

I'm new on this field of coding, and I start to create by myself a project for iOS and Android. I'm a bit lost of how I supposed to organize my code, I saw different persons on YouTube doing their ...
Dorian's user avatar
  • 1
1 vote
1 answer
63 views

Building a UITableView with fixed number of cells progammatically

I am building this pet project with UIKit. The App's main goal is to keep track of my daily expenses. The AddExpenseViewController is responsible for capturing user ...
motita's user avatar
  • 11
2 votes
0 answers
55 views

Refactoring of this massive ViewController with a UITableView in it

I'm making an application that has a UIViewController with a UITableView in order to show the favorite users that the user of ...
user15675885's user avatar
0 votes
0 answers
29 views

Manage Access Control on Swift UI Elements

I have following ViewController class with a tableView. ...
Tharindu Ketipearachchi's user avatar
0 votes
0 answers
349 views

ToDo app using MVVM with CoreData in SwiftUI

I'm trying to learn MVVM in SwiftUI using CoreData and I'm struggling with creating clean architecture. As this is my first app besides apps made during tutorial and courses it's just really simply ...
ostojan's user avatar
  • 141
1 vote
1 answer
115 views

MVVM pattern in Swift

I've been coding for some time now and since I am working alone I'm not strict in my coding structure approach(bad idea) and was only focused on getting things done which resulted in MVC(MASSIVE-View-...
Joe 's user avatar
  • 13
1 vote
0 answers
213 views

CoreBluetooth delegate to async stream

I want to use async/await by AsyncStream for Bluetooth scanning. The CoreBluetooth is using the delegate pattern. The following code provides an adapter for using ...
lotusirous's user avatar
5 votes
3 answers
181 views

Sum of natural numbers below threshold

I have this code: ...
Shum's user avatar
  • 53
2 votes
0 answers
65 views

Function for formatting data retrieved from a battery via Bluetooth Low Energy

I have the following function in Swift and am looking to improve the readability. The function takes from the deviceData object which holds maps of data like ...
Dylon Jaynes's user avatar
1 vote
1 answer
75 views

API call to list top stories using dependency injection in iOS with MVVM

I'm currently trying to find out what's the best networking architecture for MVVM applications. I couldn't find many resources and decided to go with dependency injection based architecture as per the ...
Tharindu Ketipearachchi's user avatar
1 vote
0 answers
52 views

Setting constraints to scale app's UI for consistent display across all iOS devices

For apps which don't have significant layout changes between the iPhone and iPad versions, I usually set the constraints of all UI elements (views, labels etc.) as fractions of the current device ...
Quack E. Duck's user avatar
3 votes
1 answer
309 views

UIImage downscale and compression

getFinalImageData(:UIImage) takes a UIImage and downscales its size dimensions (to 400 ...
trndjc's user avatar
  • 133
0 votes
1 answer
52 views

Understanding How To Approach A Permutational Word Search

This question is carried over from StackOverflow... First time posting here, so bear with me. The topic is constructing a search made up of a given string, and a series of letters, where each of the ...
Dan Donaldson's user avatar
1 vote
1 answer
267 views

Best way to do Input Validation on Swift/iOS/UIKit

I have the following form that creates a new "activity": For which I want to enforce the following requirements: Name => minimum # of chars: 1; maximum # of chars: 50 Description => ...
Enrique's user avatar
  • 145
2 votes
2 answers
156 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 ...
Neeku's user avatar
  • 121
1 vote
1 answer
2k views

Changing the color of some pixels in an image in Swift

My code is working perfectly fine, except for one-thing. The performance is not up-to the mark. What I am trying to achieve is I have an image with a few circles (each circle has a border with ...
Raja Saad's user avatar
  • 113
4 votes
2 answers
145 views

Fetching data closure completion

I started learning MVVM and API data fetching, so I made this code: Function loadDirector in which directorName value is ...
Jule's user avatar
  • 41
2 votes
2 answers
207 views

Initialize Swift class or struct values inline

For a Metal application, I would like to create and initalize texture object globally so it will not have to be optional, and will already be ready to use once ...
user244312's user avatar
3 votes
1 answer
129 views

Structure and readability of the code in swift ios

For a job in company I had to do a code assignment. My assignment performs all the required tasks needed to be done. But after one month the company provided me a feedback and said that we have ...
Cluadia Hedda's user avatar
3 votes
2 answers
140 views

Determine final player in a counting game

I made a function in which 17 players are counting to number N. Function as a parameter takes a number N and returns which player is going to say N. If current number is divisible by 9 the counting ...
Sah Sah's user avatar
  • 31
2 votes
1 answer
144 views

Swift code to extract most common page sequences from an Apache server log

So I received the following prompt for a code interview: "Please create an iOS app that downloads a text file from our server, parses the contents, and displays the results. The file is a ...
Russ J's user avatar
  • 149
0 votes
2 answers
166 views

How to load and get data from 2 files

I want to load 2 files and show this data in 2 strings. I trying to do it like this and it works fine. But I think it is not the best solution... How to do more elegant solution? ...
User's user avatar
  • 1
5 votes
2 answers
938 views

Better way to provide data to UIKit component from Combine pipeline

Today I'm researching how to provide data to UIKit component when using Combine pipeline. I could see tons of tutorials about how to use SwiftUI + Combine from internet, but not found anyone helpful ...
Zhou Haibo's user avatar
4 votes
1 answer
290 views

JSON parsing service

I created the following service for the purpose of sending in a file for parsing. I'm using the generics so that when I call parse() I can pass a custom type ...
Joe Scotto's user avatar
3 votes
1 answer
142 views

Swift iOS rewrite a function that use Firebase database without updating a global variable

I'm learning swift programming and i built a music trivia app for iOS that use firebase real time database. I have a function that before the game start get the number of record for each category of ...
salvatop's user avatar
2 votes
1 answer
84 views

Which is better-way to casting model

I need to convert my model to fit data in tableview cell finding better approach ...
Jaydeep Vyas's user avatar
2 votes
2 answers
173 views

What can I learn from this coding test?

So I was recently asked to complete the following challenge for an interview: Programming Problem Provide a production ready solution that accepts a new user name, validates a single string input as ...
Russ J's user avatar
  • 149
2 votes
1 answer
205 views

UIView position updates based on device motion via RxSwift

I've created a simple function to work as a level, where the dot on screen is centered when the device is completely flat. It changes position based on device orientation. I use RxSwift to update the ...
jclasley's user avatar
  • 101
5 votes
1 answer
323 views

Sorting JSON items from a site

So I recently applied to this job for iOS Developer and was invited to complete the following code challenge: As a next step, please complete this coding exercise in order to proceed with our ...
Russ J's user avatar
  • 51
1 vote
1 answer
357 views

Improving sqlite3 code in swift using c api

Trying to come up with a pattern where the code to open db, writing queries is elegant and clean while handling all possible error conditions. Following code ...
AppDeveloper's user avatar
3 votes
1 answer
100 views

Break music player into usable components in SwiftUI

I created a music player using swiftUI.I need to ask a question when I break up my player into usable components. How should I take this approach with the music player? because the music player is one ...
NinjaDeveloper's user avatar
2 votes
0 answers
25 views

Is this way of handling events in a Xamarin project memory safe?

I inherited a Xamarin project and I'm trying to find my way. The first task I completed involved creating a new reusable view and adding it to an existing screen. This was iOS specific, so I went and ...
Kevin's user avatar
  • 121
3 votes
1 answer
2k views

SwiftUI Dot indicator

I want to understand if I got this concept correctly. I should start work from ViewState; a reference type object holding the state of a view. Here it is called <...
fewlinesofcode's user avatar
4 votes
1 answer
113 views

POC for GithubUserFinder

I would like to request iOS developer community to please review my POC i.e. [GithubUserFinder][1] which I have created as part of job screening test at T-mobile Bengaluru. I have around 2 years of ...
Pooja Singh's user avatar
3 votes
0 answers
264 views

Combine asynchronous return values in SwiftUI

I have 2 asynchronous return values from 2 different classes, one from HealthKit, the other from MotionManager. I combine the outcome of these classes through a combinedViewModel. The code works, but ...
Bjorn Morrhaye's user avatar
2 votes
2 answers
339 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: ...
Win Fan's user avatar
  • 23
1 vote
1 answer
142 views

Service Locator with Lazy Loading in Swift

I am experimenting with the ServiceLocator pattern. I'd like to support lazy loading of items. ...
Teddy K's user avatar
  • 113
1 vote
0 answers
539 views

iOS Core animation cancel and restart [closed]

There is a simple movement CAKeyframeAnimation, what needs is that I can cancel and restart the animation freely. The key point of the following code, is that I ...
DNG's user avatar
  • 121
1 vote
3 answers
3k views

Create UIView programmatically in Swift

I am generating View and setting constraints programmatically in UIViewController ...
saurabh's user avatar
  • 156
2 votes
3 answers
183 views

I want to take away WebService call from UIViewController

I am using Moya to make network calls in Swift. In my ViewController I am calling the WebService and creating a model from response. ...
saurabh's user avatar
  • 156
2 votes
0 answers
598 views

Java's AtomicInteger equivalent in c#

I'm trying to replicate Android's GenerateViewId() to assign a unique Tag to dynamically created UIViews in Xamarin.iOS. ...
Olivier MATROT's user avatar
1 vote
1 answer
92 views

Initializing more than one instance object at a time in init method

I have a RadioStation class file and a view controller where I create two station objects based on this class, one for FM and one for AM. I created both of these ...
timman's user avatar
  • 149
3 votes
1 answer
76 views

Handle HTTP and BLE requests

Im implementing and designing a workflow that performs both HTTP and BLE requests. Im having trouble figuring out the best approach to design a service to handle both types of requests, and manage ...
J. Doe's user avatar
  • 45
6 votes
2 answers
1k views

100DaysofSwiftUI - Project 1 - Challenge 1: Convert temperature units: Celsius, Fahrenheit and Kelvin

This is my code to solve the challenge in 100 Days of SwiftUI by Paul Hudson. This is the first challenge in the series and I chose to convert the temperature units from C° -> F°, F° -> C°, C° -> K° ...
Kareem Moustafa's user avatar
2 votes
2 answers
176 views

Searching within a data model using an array matching multiple terms

I have a standard tableview app that displays information from a data model array that uses a custom class. There is a UISearchController to filter the data. A ...
Chris's user avatar
  • 226
1 vote
0 answers
34 views

Manage Recent List Of user and staff type objects

So I have a view which shows recent 5 staff users and 5 customers for a restaurant app. I am storing this in user default. I am also managing the currently selected object. Here is my class. ...
Prashant Tukadiya's user avatar
1 vote
1 answer
102 views

iOS: prettify random color for debugging

iOS: prettify random color for debugging I used to use random color to debug, from colors I like ...
dengApro's user avatar
  • 391
2 votes
1 answer
344 views

iOS Body-Mass-Index (BMI) app

This is "homework" from a Swift course, which I'm currently taking. A mockup and the image-assets are provided by the instructor. We are supposed to create the layout and to write some appropriate ...
michael.zech's user avatar
  • 3,980
1 vote
1 answer
333 views

Convert image to grayscale

To convert JPEG file, C function, bgraToGrayscale is called from Swift. Is there a better way to 1.allocate memory and 2.access pointers than the ways they have been done in code below? And ...
Lydon Ch's user avatar
  • 111
1 vote
1 answer
643 views

Unit Test class from iOS

I am learning to write test cases in iOS using Swift. I was stuck at testing static functions from my Utilities class, so I ...
Vishal Sonawane's user avatar

1
2 3 4 5
9