I can define c function and variable inside Objective-C class implementation like this:
@implementation MyViewController
- (void)viewDidLoad {
[super viewDidLoad];
cfunction();
}
// variable inside class
NSString *message = @"this is c function inside objective-c class";
// c function inside class
void cfunction() {
NSLog(@"%@", message);
}
@end
RESULT
this is c function inside objective-c class
This code works without any warnings and errors.
Is it valid Objective-C code?
Is it safe to define variable and c function inside Objective-C class?
Are there documentations about this language specifications?
Yes, this is correct and safe, but you should try to avoid it. If you need to have some C-function, define it in a separate file (and declare it in a separate header file).
Technically, Obj-C is a thin layer on top of the C language and you can use any C feature anywhere in a Obj-C source code. However you should conform to the coding style and not mix the two languages.