Skip to main content

Questions tagged [objective-c]

Objective-c is a highly dynamic message-based object-oriented language, superset of C, that is a primarily used for programming Apple's Mac OS X and iOS platforms.

Filter by
Sorted by
Tagged with
3 votes
3 answers
319 views

What is the best way to retain a local object which is performing an asynchronous task?

My problem is the following: inside a method I'm creating an object like this: MyObject* myObject = [MyObject new]; Then I want it to perform an asynchronous task like this: [myObject ...
Andrey Chernukha's user avatar
1 vote
2 answers
768 views

How is it that reference counting is faster on Apple silicon Intel translation than on Intel?

I can't find the exact tweet, but it was stated by Apple engineers that the retain and release operations are faster on Intel x86 translation than on standard Intel x86.
Curious's user avatar
  • 95
1 vote
2 answers
250 views

Is NSNotification in iOS a good design?

Because of some essential C++ libraries, I have to mix Objective-C and C++ in my code. But the problem is that the callback between C and Objective-C is extremely hard to design and manipulate, so I ...
Patroclus's user avatar
  • 171
5 votes
2 answers
6k views

Is it a good idea to use Singleton pattern for an API manager?

So basically I am writing a wrapper for a REST API in objective-c so that our customer can easily use them in their iOS development. I am trying to find a good design pattern for this purpose, it ...
Patroclus's user avatar
  • 171
1 vote
1 answer
174 views

Objective-C: Strategy Pattern, is mainly by selector?

To use Strategy Pattern in Objective-C, I think it is mainly by selector. To omit if...else, use Objective-C runtime, convert string matching to choose selector (Strategy). Am my understanding ...
dengApro's user avatar
  • 117
2 votes
0 answers
585 views

How to dispatch these functions in Objective C to not lock Main thread?

There's a large shared object (kind of OpenGL context) in my project. It is accessed from multiple threads. To ensure only one thread at the moments is using SHARED_OBJECT, mutex (kind of ...
olha's user avatar
  • 179
1 vote
1 answer
49 views

MVC: In iOS how to pick a view and then apply a suitable controller to it?

Per MVC design pattern as in GOF, "a view can be disabled so that it doesn't accept input simply by giving it a controller that ignores input events". That means, we decide a view first and then pick ...
Saran's user avatar
  • 397
3 votes
3 answers
368 views

Does C# have a way to use a multi-interface declared instance, or something similar when applying ISP?

My understanding of ISP is that the "client" in the definition (see below) can mean either a class that implements the interface or an instance declared with 1 of the various interface options, based ...
morbidhawk's user avatar
0 votes
2 answers
337 views

Initializing singleton properties, in init or in sharedMyClass?

So I have a singleton in Objective-C, there's one static method exposed to access the one and only instance: + (id)sharedMyClass { static MyClass* sharedMyClass = nil; static ...
Kevin's user avatar
  • 844
2 votes
2 answers
577 views

Which one is more efficient; a subclass of UITableViewController for multiple purposes or multiple sub classes each for a purpose?

Say I have two views (Table View for example) that I'd like them to do different stuff; each loads different data but behaviors are similar for most par except what happens when a cell tapped for ...
TheeBen's user avatar
  • 123
1 vote
0 answers
79 views

How to follow MVC in a standard iOS App theoritically?

I want to understand one thing in plain english that how do I actually use an standard MVC design pattern in iOS App. I know about Modal View and Controller and theoretically I know what they do(...
Ritesh.mlk's user avatar
7 votes
7 answers
3k views

Why don't constructor return bool to indicate its success or failure without having to throw an exception?

Take C++ constructors for example, we know they don't return values. Why did Bjarne Stroustrup in the beginning decide not to allow constructor returning 'false' to indicate it fails, so that the run ...
user avatar
2 votes
1 answer
940 views

In Objective-C,what is the naming convention around protocols and their implementation classes?

Is there a naming convention for protocols and concrete implementations of them in Objective-C? Specifically regarding a protocol that's used as an abstract 'service' or 'manager' class declaration. ...
Mitch Ware's user avatar
0 votes
1 answer
90 views

Does variable type specification lead to any performance difference?

Let's say I have a very long method which basically creates a responsive and resizable layout for a user interface by using a few fixed values and a few variable ones taken from an element's ...
Aluminum's user avatar
  • 191
1 vote
2 answers
928 views

Which design pattern to choose when supporting multiple analytic tools?

I have spent quite some time learning all possible design patterns but I cannot find the ideal one for the following case. I am developing an iOS app where we are using multiple analytics tools like ...
skornos's user avatar
  • 121
5 votes
2 answers
13k views

Do nested conditionals have a significant performance impact? [duplicate]

This is a question that lives in my mind from a long time. Does the use of multiple nested conditional statements impact the performance of a taken code? So far I know that programmers have created a ...
Aluminum's user avatar
  • 191
1 vote
1 answer
557 views

Mixing OOP and Non-OOP

I'm working on a command line interface text based game. I'm writing it in C but there are various ways in which I could refactor the code by using Objective-C: using NSDictionary to allow me to ...
Arc676's user avatar
  • 121
0 votes
1 answer
197 views

Swift: Creating an empty array [closed]

The following: var emptyArray = [String](); What do I need the parentheses () for? [String] says, that the array accepts strings only. But why do I have to put the () there?
PeterPan's user avatar
  • 137
23 votes
2 answers
9k views

Why does Swift not require semicolons? [closed]

I normally code in either c# or Objective-C and recently took it upon myself to learn Apple's new programming language - Swift. The first thing I noticed is that you don't need to add semicolons to ...
Memj's user avatar
  • 335
3 votes
3 answers
4k views

Why does Objective-C store objects on the heap instead of on the stack?

I have a basic understanding of what a "stack" and "heap" are. You use a stack to store items in memory that should be read and/or removed in a last-in-first-read/removed manner. To steal another ...
moonman239's user avatar
  • 2,063
3 votes
1 answer
920 views

Securing a private API used by an iOS App

I have an app that uses an API server and I do not want to have anything other than it to be able to use that API. I know this isn't totally possible, but I want to do what I can. I don't think my ...
ecnepsnai's user avatar
  • 131
4 votes
3 answers
685 views

How do you define stateless methods while keeping them together in Objective-C?

I have a few methods which are stateless: loginWithEmail: password: completion: signUpWithEmail: password: completion: resetPasswordForUsername: completion: Currently what I do is I create a class ...
Kris Gellci's user avatar
2 votes
1 answer
615 views

Why isn't the isa pointer hardwired in Objective-C classes?

I've been studying the Objective-C runtime for some years, and even hacked libobjc a little bit (both Apple's and GNUStep's), and I've been wondering about a design decision on the compilers. Every ...
paulotorrens's user avatar
0 votes
2 answers
3k views

Why can't I use an operator like plus sign to concatenate strings? [closed]

Why in Objective-C we should be typing explicit references to methods like stringByAppendingString to concatenate strings, when in some other languages we can use operators for that? For example, ...
moonman239's user avatar
  • 2,063
5 votes
1 answer
256 views

Is Apple sample code the "correct" way to go?

I'm in a place were I know how to build apps and have submitted at least 5 for different clients to the app store and wanted to step up my game. So of course I went to Apple resources and analyse the ...
Marcos Griselli's user avatar
5 votes
1 answer
2k views

Why check if object is nil

What's the point of the if statement in the following code: - (NSArray *)myMethod { NSArray *array = nil; if (!array) { array = [[NSArray alloc] initWithObjects...] } return ...
Jessica's user avatar
  • 153
1 vote
1 answer
254 views

Is Objective-C the only language with infix arguments?

One of the things I like about Objective-C is the use of infix arguments when calling a method. [myDictionary setObject:myObject forKey:@"key"]; where the method name is setObject:forKey:. Does any ...
Sam Washburn's user avatar
1 vote
2 answers
705 views

Example of writing unit test for a method

I am writing unit tests for an iOS application. I clearly understand the benefits of writing unit tests & TDD, but I am confused about what kind of tests you can write for methods like this; -(...
Clement Prem's user avatar
1 vote
1 answer
108 views

Objective-c anonymous property coding style

If I have an interface defined like @interface MyClass @property (nonatomic, copy, readonly) NSString *myString; @end so that myString is externally visible but can't be written, what would be the ...
deanWombourne's user avatar
2 votes
1 answer
7k views

How static functions are better than Class Methods in Objective-C [closed]

I was going to through this post by Mattt Thompson in which he mentions that Static functions are nicer than shoe-horned class methods I just don't see any flaw with Class methods in Objective-C ...
Evol Gate's user avatar
  • 129
6 votes
1 answer
2k views

How do you write tests for methods that interact with data in system files?

I'm trying to be proactive about writing an iOS app in a test-driven manner. However, I'm stumped as to how to test a method that is to interact with real system files. For those familiar with iOS, I'...
H K's user avatar
  • 193
-2 votes
1 answer
681 views

How come the keyword for declaring a class is 'interface' [closed]

What is the relationship between a class and an interface in objective-c? How come we declare a class using @interface instead of @class?
chopper draw lion4's user avatar
3 votes
1 answer
709 views

Does key-value observing between model and view violate MVC?

In MVC the Controller is the go-between for the View and the Model. So the Controller should be the one that observes or receives changes from the Model and View and updates the other accordingly. I ...
Korey Hinton's user avatar
  • 2,676
15 votes
3 answers
4k views

Massive View Controller - IOS - Solutions

I'm sure every new iOS developer has the following problem: The View Controllers get very fast crowded with code for various purposes, easily getting to 500 + lines of code. This is how it looks like ...
Ravul's user avatar
  • 159
2 votes
1 answer
2k views

Performance of Class methods vs singleton instance methods

In my app, I'm using both strategies: I have a Utils class, it only has class methods that I call for doing common global methods, like NSString validation, etc. I have an app-wide singleton class ...
Dhiraj Gupta's user avatar
8 votes
1 answer
3k views

Inheritance, Composition and Protocols

I'm reading a book on general object oriented concepts to try and gain a solid understanding of everything. One thing that is throwing me off is the difference between Inheritance and Composition. I ...
Henry F's user avatar
  • 211
12 votes
1 answer
2k views

Naming convention for iOS/OSX open-source projects

Not always but most of the time, you will find iOS or Mac OS X open-source projects with names starting with the initial letters of the author first and last names. If a project were to be authored by ...
Stéphane Bruckert's user avatar
5 votes
2 answers
523 views

Do iOS frameworks require the same internal versioning as OSX frameworks?

I have been reading through the apple documentation for creating frameworks for OSX and iOS. Reading about the structure of frameworks, I began to wonder if there is really any need to create the ...
tecknut's user avatar
  • 159
1 vote
3 answers
470 views

Security in an iOS game?

I'm part of a team building an iOS game which has multiplayer elements. A concern right now is how to make the game more secure, from user manipulation. I know there's a lot of multiplayer games out ...
Andrew's user avatar
  • 179
19 votes
6 answers
2k views

The importance of duplicate code removal [duplicate]

I tried to explain to a coworker the gravity of having duplicate code in a project, on this piece of code: + (void)createIapInParse:(SKPaymentTransaction *)transaction { Reachability *reach = [...
Iulian Onofrei's user avatar
0 votes
1 answer
613 views

What effect does using multiple childViewControllers views inside a ContainerViewController have on memory?

I have three childViewController views inside my ContainerViewController and these three views are inside a horizontal scroll view. My intention is to build an app that has a custom camera on one ...
Vlad Bahtjak's user avatar
0 votes
1 answer
776 views

Macro guard in Objective-C

I have noticed that many famous libraries written in Objective-C (eg. AFNetworking) use the macro guard inside their header files. Im aware that the #import directive, which works exactly like #...
maross's user avatar
  • 103
0 votes
1 answer
552 views

Approach to managing multiple services like Evernote, Google drive, dropbox in iOS

I'm trying to think up a scenario when I'd have three different forms of NSData (or whatever) to be sent to three different services like Evernote, Google drive, Dropbox. Granted, each of those has ...
user134611's user avatar
1 vote
1 answer
679 views

How does Telnet work?

Is telnet just a simple socket connection? I usually have a difficult time in the networking area so I use some code from the internet to help me out, but I can't seem to find a library for Telnet in ...
AshotN's user avatar
  • 113
118 votes
5 answers
63k views

How can Swift be so much faster than Objective-C in these comparisons?

Apple launched its new programming language Swift at WWDC14. In the presentation, they made some performance comparisons between Objective-C and Python. The following is a picture of one of their ...
Yellow's user avatar
  • 1,273
1 vote
1 answer
234 views

Should I implement a function or a method?

Once in a while I encounter a C function in my colleagues' code. Mostly it is in some helpful objective categories, and those functions are mostly an internal calculation of something or a ...
Earl Grey's user avatar
  • 628
4 votes
2 answers
30k views

Calling static method from instance of class

As a developer I am fan of static methods. Recently I come across difference between OOP languages about this static methods. All OOP language use static method to access any method without ...
CRDave's user avatar
  • 151
0 votes
1 answer
140 views

Drawbacks to redefining method in precompiled header

I have a lot of calls to NSLog(...). I need to change all of these calls to CLSNSLog(...). So I added this to my precompiled header (.pch): #import <CrashlyticsFramework/Crashlytics.h> #define ...
Rey Gonzales's user avatar
3 votes
0 answers
346 views

Manage the persistence of entities on iOS in several places: CoreData on the device, iCloud and on a REST API

For the needs of a project, I would persist the datas contained in Core Data in several places depending on the state of the user. If the user is logged to my API -> Persist the datas on my API. If ...
Jean Lbr's user avatar
  • 179
1 vote
0 answers
1k views

What are the bad points of using Core Data for iOS like an ORM

I just starting to use Core Data for my iOS app and I am thinking about how use Core Data for my needs. What are the features of my app: The user look for products proposed from a catalog. The user ...
Jean Lbr's user avatar
  • 179