Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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.

1
vote
2answers
37 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 ...
2
votes
1answer
118 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 ...
0
votes
1answer
62 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 ...
2
votes
0answers
292 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 ...
1
vote
1answer
34 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 ...
3
votes
3answers
268 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 ...
0
votes
2answers
82 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 ...
2
votes
2answers
97 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 ...
1
vote
0answers
52 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(...
6
votes
8answers
1k 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 ...
2
votes
1answer
414 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. ...
0
votes
1answer
75 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 ...
0
votes
2answers
505 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 ...
3
votes
2answers
1k 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 ...
1
vote
1answer
322 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 ...
0
votes
1answer
161 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?
1
vote
0answers
48 views

Xcode rolling video architecture

I am going to writing an App that records video but to save on memory space I want to allow the user to continually record and then, when something happens, they can save that period of time (post the ...
17
votes
2answers
6k 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 ...
3
votes
3answers
2k 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 ...
3
votes
1answer
459 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 ...
4
votes
3answers
348 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 ...
1
vote
1answer
328 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 ...
0
votes
2answers
1k 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, ...
4
votes
1answer
221 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 ...
5
votes
1answer
335 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 ...
1
vote
1answer
166 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 ...
2
votes
2answers
451 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; -(...
1
vote
1answer
101 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 ...
2
votes
1answer
4k 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 ...
6
votes
1answer
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'...
-2
votes
1answer
298 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?
1
vote
1answer
524 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 ...
16
votes
3answers
3k 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 ...
2
votes
1answer
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 ...
6
votes
1answer
2k 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 ...
12
votes
1answer
1k 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 ...
5
votes
2answers
394 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 ...
1
vote
4answers
423 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 ...
19
votes
6answers
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 = [...
0
votes
1answer
436 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 ...
0
votes
1answer
385 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 #...
0
votes
1answer
535 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 ...
0
votes
1answer
590 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 ...
114
votes
5answers
58k 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 ...
1
vote
1answer
158 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 ...
4
votes
1answer
15k 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 ...
0
votes
1answer
126 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 ...
2
votes
0answers
319 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 ...
1
vote
0answers
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 ...
6
votes
2answers
3k views

Objective-C style: Do I implement factory methods or init methods?

I'm new to Objective-C programming, and creating various classes for an iOS application I'm working on. When creating objects, it seems like many classes in the built-in frameworks use the "static ...