views:

221

answers:

3

Hi all,

Apple's rejected my app because it says:

"3.3.1 Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited)."

The non-public API that is included in your application is animationDidStop:finished:context:.

This is my method in which I am using the call to above-mentioned method:

- (void)hideMsg
{
// Slide the view off screen
CGRect frame = self.view.frame;
int retractY;
int retractX;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];

        retractY = -190;
        retractX = 0;

frame.origin.y = retractY;
frame.origin.x = retractX;
self.view.frame = frame;

//to autorelease the Msg, define stop selector
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];

[UIView commitAnimations];
}

I'm using this method to display a sliding message after occurence of certain event.

But I have nowhere defined this method. When I tried to find it was only found in CAAnimation.h, UIView.h.

Has anybody encountered with the same problem? How did you fix it? Any advice is appreciated.

Thanx in advance.

A: 

animationDidStop is an iOS delegate. You should use another name for your own selector.

ohho
+3  A: 

If you need to perform some action (like releasing objects) when the animation has finished you should define your own method then pass a selector for it to UIView setAnimationDidStopSelector.

For example:

-(void) messageSlideFinished {
 // do some stuff here
}

Then when setting up the animation you would do

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(messageSlideFinished)];
mad-dog-software
Thanx mad-dog-software.. It helped..
neha
+2  A: 

The whole point of setAnimationDidStopSelector: is that you are telling the system to call your own custom method when an animation completes. So, if you are going to pass in that selector you need to define that method in your class yourself:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
   // do whatever.
}

Note the documentation for setAnimationDidStopSelector: says you must use a selector of this form, but in reality you can also use a shorter one like mad-dog described. But, it's better to get the animationID and context and other items to examine.

You need to add the method to whatever class that code is in because you are passing self as the animation delegate.

They probably also have an internal UIView method of the same name for some reason, which is why you are being accused of using an undocumented API.

Kendall Helmstetter Gelner
The mail also says: "If you have defined a method in your source code with the same name as the above mentioned API, we suggest altering your method name so that it no longer collides with Apple's private API to avoid your application being flagged with future submissions." Then here if I define the method with my stuff in it, will it not collide with the Apple's private api method?
neha
You could just name it myanimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context to be safe (the exact name does not matter as long as the types of the arguments accepted are the same). It's weird though because I have used that same method in other apps in the store, perhaps it's a new method just added.
Kendall Helmstetter Gelner