(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
[[controlfile alloc]scedule1];
return YES;
}
i got potential leak of an object allocated on [[controlfile alloc]scedule1] when i build & analyze
This is allocating an instance of class
controlfileand then callingscedule1on the allocated object. (Note that it’s not yet initialized; you should have initialized it first by callinginit). Then the object (which you allocated) is never referenced again. Thus, you have leaked it.You really need to do something like this:
This assumes that
ControlFileis a class. If it’s an instance variable (as indicated by the all lowercase text and lack of declaration in your code), then you want this:For every call to
alloc, you must call eitherreleaseorautoreleasewhen you are done with the object. You are not doing that here, and thus you have leaked the object.