I'm still really new to Objective-C, but I've successfully created my own app and I'm having a little trouble implementing the video ads for Chartboost.
I'm implementing a reward video which creates a pop-up, offering the user a free life in exchange for watching a video. I can get the pop-up working fine. But I can't figure out how if the user has decided to watch the video or not.
I do know the Chartboost.h file has the proper method for this, listed under #optional, but I have no clue how to use this in my Level1.m file
- (void)didClickRewardedVideo:(CBLocation)location;
Also note, that Chartboost.m is not included in the framework they've given me.
Thanks for any help!
I'm not familiar with the Chartboost library, but it sounds like ChartboostDelegate is a protocol that you need to implement in your own code, as with any delegate object. The library is going to call didClickRewardedVideo: on some registered object when the rewarded video is clicked. Have you set yourself as a delegate of a Chartboost instance, or similar?
So in your Level1 class you must declare conformance to the protocol and implement the method (if you need to... it's optional after all):
#interface Level1 () <ChartboostDelegate>
#end
#implementation
// ...
// ...
- (void)didClickRewardedVideo:(CBLocation)location
{
// Video was clicked. Do something appropriate.
}
#end
You can read more about the delegation pattern in Cocoa in the Concepts in Objective-C Programming documentation.
Related
I was looking at WWDC Video Advanced Techniques with UIKit Dynamics. I tried to go through the explanation how to create a customized transition using UIDynamics. When the UIGravityBehavior will be created, they also use a method I can't access (second line):
[self.gravityBehavior = [UIGravityBehavior alloc] initWithItems:#[myView]];
[self.gravityBehavior setXComponent:0.0 yComponent:3.0];
I also found a Github project where you can see the runtime Headers of UIGravityBehavior. There the method is available. I don't understand why the method is called inside the video. Is this just an explanation what happens when the app is running or do I have to implement a specific delegate to get access to it?
There's a method called didLoadFromCCB that you can implement for any class that has been created in SpriteBuilder. This method is called when Cocos2d loads the class from a CCB file.
What I want to know is: where does this method come from?
Xcode doesn't seem to know it exists, as it doesn't autocomplete.
I'm not having any problems with the method, it's getting called and everything is working perfectly, I'd just like to know where it comes from.
Also, I'd like to know if there is any documentation that lists methods like this that can be called on classes loaded from CCB files. I've had a look around www.spritebuilder.com, but there doesn't seem to be anything of that nature.
CCBReader sends this message. You can search the project in xcode if you need to find its exact origin.
The mistake is that this method wasn't declared in any of the CCBReader headers and isn't in a protocol either, therefore Xcode won't autocomplete it because it's considered a private method. This will be fixed eventually.
There is currently no CCNReader documentation besides the code itself. But didLoadFromCCB is the only method CCBReader will send to nodes.
EDIT: I opened an issue regarding autocomplete of didLoadFromCCB, it's been bothering me too.
Is there any way to block access to certain application programmatically on iOS? Using private APIs or workarounds is not a problem in my case.
Thanks in advance!
This tutorial does basically what you want to do, assuming your second sentence means you're working with jailbroken iOS.
Basically you write a hook for the SBApplicationIcon class that looks something like this (code not mine):
%hook SBApplicationIcon
-(void)launch
{
NSString *appName = [self displayName];
if ([appName isEqualToString:#"blah"]) {
// react accordingly
}
%orig; // Call this if you want to proceed with launching the app in question.
}
%end
You'll need to link against UIKit, I believe.
EDIT: to clarify, the above code is using Logos. I'm sure it's also possible using the Objective-C runtime directly, but I'm not familiar with that.
There are certain apps that block access out there that force you to input a password. For example, you can take a look here https://apple.stackexchange.com/questions/31154/how-do-i-password-protect-access-to-specific-apps-in-ios to find some ideas. Hope this helped!
I have been using a storyboard, and I have not gotten into the code much, and now it seems that it is time.
I have a form and when the submit button is pressed, do I need to put code to handle that into the .h or the .m file? Also, are there examples of handling a button and making a remote call that I can reference somewhere?
Thanks!!
You might find Apple's Your First iOS App document helpful; it covers connecting buttons to actions in code.
As for making a remote call; there are many ways. I would suggest you look into NSURLConnection and friends as a stating place, but there are many, many libraries to help with this, such as RESTKit.
Now that 5.0 is launched and we can discuss it without breaching Apple's NDA, I have an issue with the new version of NSURLConnection. This has a new delegate, NSURLConnectionDownloadDelegate with two key methods.
connection:didWriteData:totalBytesWritten:expectedTotalBytes: is invoked repeatedly while the file download is progressing
connectionDidFinishDownloading:destinationURL: is called once when the download is complete.
The downloaded file should then be at destinationURL (at least for the life of this method - the intent is that you get it and move it somewhere permanent). The issue is : it's not there. That directory is empty. I have reported this as a bug to Apple and they tell me it is a duplicate of an issue that they are already aware of.
If anyone has a workaround for this, or finds they can use this delegate successfully, please let me know.
UPDATE 10/17/2011 : I've given up on this and gone back to the old delegate which still works fine in 5.0 even though the documentation says the delegate methods are only available thru 4.3.
Apparently only for use with Newsstand apps. This guy might have found a work around:
http://adamernst.com/post/18948400652/a-replacement-for-nsurlconnectiondownloaddelegate
Alternatively, just use NSURLConnection. But heads up if you implement the NSURLDownloadDelegate methods, they appear to override the standard NSURLConnection delegate methods. If it's the handy didWriteData: method of NSURLConnectionDownloadDelegate that you want, e.g. to update a UIProgressView, you can achieve the same by grabbing the total file size from the http response, and by using the didReceiveData: method of NSURLConnection.
Documentation tells the file is only guaranteed to exist while the delegate method is called so you will need to copy it somewhere else the moment the delegate method is called.
Google tells me people are having problems when the Server sends a cryptic filename and/or mime-type.
Folks,
I've recently discovered this new NSURLConnectionDataDelegate protocol. However, the iOS 5 documentation is incomplete.
The New NSURLConnectionDataDelegate protocol is in the documentation, but the new version of NSURLConnection that uses it is not. That documentation still tells us to use the now deprecated NSURLConnectionDelegate protocol methods.
I gather that NSURLConnection will now download data from a remote URL directly to a file on the local disk, much like the NSURLDownload class in Mac OS. How do I figure out how this works?
The header for NSURLConnection hints that the connection object deduces what you want based on which version of the NSURLConnectionDelegate protocol the delegate conforms to. That seems really screwy. I've never heard of using the protocol conformity of a delegate as a way of controlling the behavior of a class before.
Even now NSURLConnectionDownloadDelegate doens't work.
Here is a good replacement:
http://github.com/jbrennan/JBContainedURLConnection