Cannot resolve the error Collection element of type 'void*' is not an Objective-Object (old title; Expected'; 'at end of declaration list)

Asked 1 years ago, Updated 1 years ago, 273 views

*You answered the question "Expected'; 'at end of declaration list error cannot be resolved" which I posted before, and after correcting it, a new error occurred, so I edited the question. 内容

Objective-C cannot resolve the Collection element of type 'void' is not an Objective-Cobject error.
This is NSAray
_lines=@[@"A", @"B", @"C", nil ]
I would appreciate it if you could tell me the cause.

#import "ThirdViewController.h"

@ interfaceThirdViewController()

@end

constintChangeCheckCell=1;
NSMutableArray* checkboxArray;
NSArray*_lines=@[@"A", @"B", @"C", nil ];

@implementationThirdViewController{

}

- (void) viewDidLoad{
    superviewDidLoad;

ios xcode objective-c

2022-09-30 21:58

1 Answers

The underlying problem is

NSArray*_lines=@[@"A", @"B", @"C", nil ];

The last semicolon of is missing.However, the location of the declaration and initialization of the variables is not good, so the code you want to write is probably as follows:

#import "ThirdViewController.h"

@ interfaceThirdViewController()

@end

constintChangeCheckCell=1;
NSMutableArray* checkboxArray;
NSArray*_lines=@[@"A", @"B", @"C", nil ];      

@implementation ThirdViewController


- (void) viewDidLoad{
    superviewDidLoad;

You cannot declare variables that are not inside a function between @implementation and @end.
ThirdViewController If you want to declare a variable that is visible only in ThirdViewController.m that is not a member of the class, you should write it outside @implementation.

Also, if checkboxArray and _lines are members of the class, the variable declaration should be done between @interface and @end in ThirdViewController.h to initialize the variable with viewDidLoad>.

Corrected questions

The {} after the @implementationThirdViewController is unnecessary.


2022-09-30 21:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.