Is this the right way to create and call a class for an iphone application?

I have this class
loader.h

#import <Foundation/Foundation.h>
@class Reachability;
@interface loader : NSObject {

}
- (void)startLoading;
@end

loader.m

#import "loader.h"
#import "Reachability.h"
@implementation loader
- (void)startLoading{
    NSLog(@"Check network");
}
@end

Is the code below the correct way to include the specified class and use it

in my .h file I put

@class loader;

and in the .m file

#import "loader.h"

and i use this code

- (void)viewDidLoad {
loader *myLoader = [loader alloc];
[myLoader startLoading];
[super viewDidLoad];
}

Is this the right way? use class

I want the bootloader class to change and check the Internet connection, and I'm trying to start with something :) thanks in advance :)

+3
source share
1 answer

This is normal for you, except for some parts:

  • You leak myLoader without releasing or releasing it

  • You may need the init method so you can fill in some data (for me this is not a convention)

+1
source

Source: https://habr.com/ru/post/1767615/


All Articles