in my project i created a class viewTransistion
#import "viewTransition.h"
#import "quiz.h"
#import "mode.h"
#import "result.h"
#import "aboutGame.h"
#import "ViewController.h"
static UIView *cview=nil;
static quiz *quizObj=nil;
static mode *modeObj=nil;
static result *resultObj=nil;
static aboutGame *aboutGameObj=nil;
static ViewController *viewControllerObj=nil;
@implementation viewTransition
+(void) viewsTransitionCurrentView:(id)currentView toNextView:(NSString*)nextViewName
{
if(nextViewName == @"quiz")
{
quizObj = [[quiz alloc]init];
cview = quizObj.view;
NSLog(@"quizObj=%d", [quizObj retainCount]);
}
if(nextViewName == @"mode")
{
modeObj = [[mode alloc]init];
cview = modeObj.view;
NSLog(@"modeObj=%d", [modeObj retainCount]);
}
if(nextViewName == @"result")
{
resultObj = [[result alloc]init];
cview = resultObj.view;
NSLog(@"resultObj=%d", [resultObj retainCount]);
}
if(nextViewName == @"aboutGame")
{
NSLog(@"aboutGameObj=%d",[aboutGameObj retainCount]);
aboutGameObj = [[aboutGame alloc]init];
cview = aboutGameObj.view;
}
if(nextViewName == @"viewController")
{
viewControllerObj = [[ViewController alloc]init];
cview = viewControllerObj.view;
}
[UIView transitionFromView:[currentView view] toView:cview duration:2 options:UIViewAnimationOptionTransitionCurlUp completion:^(BOOL finished) {}];
[currentView release];
cview = nil;
}
@end
its purpose is to perform view transition so i don't have to write code again n again
first i created method and variables of this class as non static...
i checked on device i was getting leaks maybe because i am alloc initing and not releasing objs in if statements
if i release objs in the last i can't perform view transition because on the next view i want to go to is destroyed
......................................
to check i converted this class methods and variables to static so i can check retain counts
the reason why i converted to static...if every time new instance is created of this class i will always get retain count 1 of current instance
now for the first time i execute this it works fine but if you look at aboutGame if block the first execution prints 0 next time if i want to go again on this page the NSLog line becomes zombie???
......................................
in the last line [currentView release] is to remove root view controller ... but i didn't alloc init this i am not the owner so why i should release it.. i saw code in a book to release view controller.
......................................
which is the best way to implement this kind of situation static or non-static
i am using this class method and variable as static and its working fine no leaks no zombies no problem?????
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)