Git Product home page Git Product logo

Comments (14)

salmanlodhi avatar salmanlodhi commented on June 27, 2024

When I paused the execution in Xcode.... program is stuck on this piece of Apple provided code


void
dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);

DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
void
_dispatch_once(dispatch_once_t _predicate, dispatch_block_t block)
{
if (DISPATCH_EXPECT(_predicate, ~0l) != ~0l) {
dispatch_once(predicate, block);
}
}


..... exactly on dispatch_once(predicate, block); function

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

That's a pretty basic couple of lines of code. If it's hanging anywhere it is in the allocWithZone: method of the superclass, which is simply an NSObject. So there's really not much that can fail here, unless you have your project setup incorrectly with regards to ARC/Non-ARC.

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

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 ....

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

Now I created a new project and its getting stuck on same line with Simulator and Device :(

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

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.

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

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

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

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

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

How about i use some global variable value to determine ... if it needs to be instantiated ?

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

That's exactly what static dispatch_once_t onceToken; is doing. After the token is set on the first execution (thus why you are passing it in by reference to dispatch_once with &onceToken), dispatch_once does not fire what is in it's block. Are you calling these methods from a thread other than the main thread?

This code is running fine on tens of thousands of devices in production.

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

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....

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

Not sure what to say without seeing the project.

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

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

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

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......

from larsadcontroller.

salmanlodhi avatar salmanlodhi commented on June 27, 2024

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 :)

from larsadcontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.