I need to know if googletag.pubads().disableInitialLoad() was called, in which case I'll load an ad using a display and a refresh calls, otherwise I'll load it using just display. My assumption is that if I always call display plus refresh I will get 2 ad requests unless disableInitialLoad had been called.
Is it possible to know that?
There is an undocumented variable on pubads that internally saves the state of disableInitialLoad, because it is undocumented you have to use it under your own risk.
the variable is window.google_DisableInitialLoad
Hope it is still usefull to you.
There is a method in GPT for doing this which is: isInitialLoadDisabled()
And as Claudio wrote - it's good practice not to use undocumented variables.
Undocumented variables might not do exactly what you think they do - and their behaviour might change at any point (see avoiding common GPT implementation mistakes).
Related
I'm trying to find out how to use Eclipse Milo, and finding out how subscriptions go. I can easily get any MonitoringMode.Reporting mode subscription to work, but when I use Sampling it doesn't call the callback method (as expected). According to the docs it's supposed to "queue" up the values without calling the callback, but I can't find any place I can access that queue or anything similar. The UaMonitoredItem doesn't have anything in its interface that looks like it, neither does the request.
It's probably something obvious, but what am I doing wrong?
Thank you in advance!
Answered in the GitHub repo discussions, but for posterity:
MonitoringMode.Sampling simply means the server continues to sample the underlying but does not report the values to the client.
The queued values are not available to you. If you change back to MonitoringMode.Reporting then they would be the first values reported for that item.
I think this should be simple, but im having a real hard time finding information about this topic. I have made a static library and have no problem getting the basics to work. But im having a hard time figuring out how to make a call back from the static library to the main APP.
I would like my static library to only use one header as front, this header should contain functions like:
requestImage:(NSString *)path;
requestLikstOfSomething:(NSSting *)guid;
and so on..
These functions should do the necessary work and start a async NSURLConnection, and call back to the main application when the call have finished. How do you guys do this, what are the best ways to callback from a static library when a async method is finished? should i do this with delegates (is this possible), notifications, key/value observers. I really want to know how you guys have solved this, and what you regard as the best practices.
Im going to have 20-25 different calls so i want the static library header file to be as simple as possible preferable only with a list of the 20-25 functions.
UPDATE:
My question is not how to use delegate pattern, but witch way is the best to do callbacks from static librarys. I would like to use delegates but i dont want to have 20-25 protocol declarations in the public header file. I would prefer to have only one function for each request.
Solution choosen:
i choose the solution from erkanyildiz with the help of a target parameter, i know its pretty low tech, but it was for me the cleanest solution. My goal was to keep the header file as small as possible. Thanks to everybody for they input, i will for sure look more into borrrdens solution with grand central dispatch when i get the time. user1055604 solution with a couple of "standard" delegates for replys is also one i like. So again thank you all for inputs.
Thanks in advance.
Best regards
Morten
Delegation pattern is a good way to do it.
You can check these pages:
http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW18
http://en.wikipedia.org/wiki/Delegation_pattern#Objective-C_example
As another approach, you can use a target parameter in every method you have.
And schedule callbacks on those targets, checking if they are responding to your callbacks using respondsToSelector
Look here for an example with delegates: How to perform Callbacks in Objective-C.
It shouldn't matter that the callback is executing from within a static library.
Static libraries are a compile/link time phenomenon. As such, calls to and from within static libraries are transparent to the application at runtime.
If you would rather not have one callback protocol declaration for each function in your static library, start with looking at what each callback would return if you did, forcefully, implement it as a callback.
From there on, find what's in common between them and bind the common elements together in a class which will serve as an interface for the responses. You may need more that one such class.
As an example, look at NSURLResponse:
NSURLResponse declares the programmatic interface for an object that accesses the response returned by an NSURLRequest instance.
NSURLResponse encapsulates the metadata associated with a URL load in a manner independent of protocol and URL scheme.
This class is used by NSURLConnection in its didReceiveResponse delegate method. In the worse case, you will end up with a couple of callbacks instead of a noisy header file. Happy coding. :-)
Try making your function calls using Grand Central Dispatch. It's quite simple, and very powerful. Here is a sample of how to make an async call with a callback:
http://pastebin.com/xDUKm6wh
This paste bin is complaining about errors, but take note of the pattern. It should work just fine.
I have read about the CoreTelephony class and in this CTClass can check caller and find state of call....
But when and how to use this......
I think my application goes to background when call start..
help please or correct me......
It is not possible with the official SDK. The best that you can do is determine if the user is on a call. You can do this by inspecting the size of the status bar frame.
[UIApplication sharedApplication].statusBarFrame
If your asking if you can track phone calls in the background, you can't in all situations.
If you want to know if, at any point in time, when your running, you can. You can access the 'CTCallCenter' currentCalls property and it will give you the state of the call at that point in time.
If you want to track if a incomming call the cause of your application going to the background, you can use the 'CTCallCenter' callEventHandler property.
Not quite sure what you're trying to accomplish but after the call ends the user should automatically be brought back to the app.
It's not possible to get this information with the current SDK, most likely for privacy reasons. I'd recommend filing a feature request with Apple (http://radar.apple.com) however, I doubt it's something they're likely to include in the future.
is there any best method to maintain global variable in iphone sdk? if i change it, it will affect in all controllers,views of that iphone application?
Globals are currently considered ugly, but they are a type of unprotected pre-allocated pre-initialized singleton, and all there was in computer programming best practices 50 years ago (1st edition of Knuth's books, etc.). The best method of maintaining globals includes using a lot of very clear comments so that you can consider something else when it's time to make the code more modular and reusable (potentially at some cost in code size).
To answer the OP's question, if you modify a global, then any controllers or views (and any C or Objective C code in the same thread that doesn't "cover" the globals name) that reads that global will get the newest value. But that new value won't be "pushed" immediately. Those views or controllers won't notice any new value until some method eventually is called that actually reads the global variables.
If you need a view or controller to respond faster, then you will need notifications or key-value observing rather than just modifying a global variable.
Globals are ugly. Better to use a singleton "Data Manager" class that contains all your data, and then use either notifications or key-value observing to update your ViewControllers about changes.
Hi I just picked up Obj-C and quite dislike its manual memory management.
I decide to go with its Garbage Collection, by adding
objc_startCollectorThread();//garbage collection
in my Main() and change the garbage collection value to [-fobjc-gc]
So is that all I need? So I can program "freely" like I do in Java/Python..etc?
Yes you are right, but in case any iPhone programmer comes by and thinks "oh sweet!", please note that the iPhone doesn't support Garbage Collection yet (ever?). So this is the MacOS only solution.
Note that -fobjc-gc means that you still use retain/release (when writing a Framework/library); you probably want -fobjc-gc-only if you want to get rid of the reference counting code completely.
As other said, there is no garbage collection in iPhone.
If you are writing a Desktop Cocoa app, all you need is the -fobjc-gc-only flag, without the explicit objc_startCollectorThread() startup function.
Basically, yes. This is covered in Apple's documentation. You may also need occasional calls to
objc_clear_stack
But this is optional, to ensure stack retained object lifetimes are as short as needed.