All Questions
Tagged with objective-c singleton
617
questions
1
vote
0
answers
36
views
Reference variable in Store.swift class from Objective-C file using singleton pattern giving Linker command failed error
I am trying to reference a variable in a Swift class from an Objective-C view controller.
I can reference functions and variables in other Swift Classes from this Objective-C class. However, when I ...
4
votes
1
answer
709
views
Singleton pattern in Objective-C using a class property [duplicate]
I'm trying to create a singleton class in Objective-C that will also be consumed in Swift. I'd like the singleton instance to be accessible in Swift as a property.
It appears that Apple does something ...
0
votes
1
answer
1k
views
How to check if a Singleton is already initialized?
I have a Singleton class in Objective-C. I want to know if the shared object is already initialized or not, before accessing sharedInstance. How can I do so?
+ (id)sharedInstance {
static ...
0
votes
1
answer
62
views
__block modifier creates unreadable memory
Now Im developing a banner showing feature in iOS
It's a singleton which shows banner on the upper part of screen when user logs in.
It's basically a shared view with a class method showWithName...
@...
0
votes
0
answers
20
views
No known class method for selector 'testPrint' while calling swift singleton function in objective c function [duplicate]
I have a swift singleton file where I have a function to be called, but when I call it in my objective-c file I get the error.
class TestSimulator {
static let testSim = TestSimulator()
@...
1
vote
0
answers
35
views
Differences in behavior running on device w/ Xcode vs. running on device w/o Xcode
I'm a novice working through an old Objective C XCode project, when I noticed some unexpected behavior: a singleton behaves as expected when I run the project on an iPhone XSMax from XCode. It behaves ...
1
vote
1
answer
360
views
What is the proper way to create a thread-safe singleton?
We have a subclassed NSNotificationQueue that has some custom methods that enqueue a notification inside of a dispatch_async call in order to get out on the main thread.
We have a class method, ...
3
votes
1
answer
537
views
Swift Singleton access in Objective-C triggers EXC_BAD_INSTRUCTION (EXC_I386_INVOP)
I've created a singleton object in Swift 4.2 and am attempting to access it (call a couple methods) in an Objective-C class. However, when calling the instance in Objective-C, the app crashes with the ...
0
votes
1
answer
70
views
presentViewController from sharedInstance of utility class
I would like to present an MFMailComposerViewController from some code that resides deep within in a utilities class accessible via a shared instance.
When I try it with
[self presentViewController:...
0
votes
4
answers
190
views
Is there any way to use global Static dictionary could able to access on all view controller in objective-c ios?
I am trying to implement one static global dictionary that can able to access on all classes. is there any other way other than singleton. i tried a-lot in stack overflow i couldn't get any solution ...
2
votes
1
answer
163
views
Retain cycles with a singleton in Objective-C
I have a singleton class named MyManager. I use self inside of its blocks: requestSomeInfo and requestSomeInfoWithString.
And requestSomeInfoWithString method gets self.string as a parameter.
Does ...
0
votes
0
answers
37
views
IOS/Objective-C: Best way to clear ivars or property values in SharedInstanceSingleton
I call a sharedInstance of a class to carry out certain tasks. Some of the methods make use of properties. I am running into issues, however, of clearing these properties so they do not persist.
I ...
-2
votes
1
answer
591
views
Access singleton sharedInstance in Objective-C class from Swift class in combined project
I have an objective-C project in which I have added a Swift class. I would like to access a shared instance of an Objective C class from my Swift code but I can't find any examples of how to do this. ...
0
votes
1
answer
96
views
Are my Objective-C singletons thread safe?
I've been reading around and its hard to get a clear feel if I have written a thread safe implementation here.
My getter looks like
+ (MySingleton *)getSingleton
{
static dispatch_once_t ...
1
vote
2
answers
56
views
Why self=[super init] ensure the singleton pattern?
I read many implementation of singleton pattern in Objective-C, and lots of the code contain such a line in the init method:
if ((self = [super init])) {
...
}
And according to this page, which ...