-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code hangs #8
Comments
When I paused the execution in Xcode.... program is stuck on this piece of Apple provided code void DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW ..... exactly on dispatch_once(predicate, block); function |
That's a pretty basic couple of lines of code. If it's hanging anywhere it is in the |
ARC is disabled.... only missing thing was the compiler flag for LARSadcontroller.m .. I even added that ..... but still same issue This code works fine on simulator but only hangs on iPhone .... |
Now I created a new project and its getting stuck on same line with Simulator and Device :( |
It's your environment. There is nothing wrong with the code you're talking about. I can say that with confidence because the section in question that it's "hanging" on is all Foundation code and not my own. Try cleaning your build, deleting the app from both the simulator and the device, close Xcode, and restart your computer. Also, try running the sample project included with the source code. |
Okie..its all happening due to threading...if i remove this dispatch_once thing then it works fine...only thing is that it keeps loading again and again |
That's because dispatch_once is the singleton initializer that guarantees that the system will only call it once and it will be a no-op on subsequent calls |
How about i use some global variable value to determine ... if it needs to be instantiated ? |
That's exactly what This code is running fine on tens of thousands of devices in production. |
I know your code is fine..... it works in other project made by me I am calling this code in view will appear of the first View Controller that the app loads .... i created a new project .... with only one view controller then it worked fine.... now as soon as i included my other view controllers (already written previously)........ same behavior is returned.... |
Not sure what to say without seeing the project. |
could this be possible reason "dispatch_once will deadlock if the something in the -init method calls the +singleton method. " source : http://cocoasamurai.blogspot.com/2011/04/singletons-your-doing-them-wrong.html |
wait a minute .... i just checked that i load data from files in my app delegate.... in function didFinishLaunchingWithOptions if i remove data load function then ads are displayed...... |
I created a global variable which i initialize in didFinishLaunchingWithOptions function in delegate...... In rest of code in just refer to this variable which is of type LARSAdController. Problem Solved :) |
I created a new project for your code. Its working fine on simulator.
As soon as i test on IPhone4S .... Program hangs during execution of below code
static LARSAdController *_sharedManager;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedManager = [[super allocWithZone:NULL] init];
});
So somehow when its creating the manger in the block..... its delayed or kind of stuck ..... Any idea what is missing ???
The text was updated successfully, but these errors were encountered: