Can you send the backtrace of the crash ("bt" in LLDB)?
> Am 16.07.2023 um 15:23 schrieb loserist <loser...@88.com>: > > Hi all! I seem to have found the problem.the problem is that the user-defined > class is not working properly, see the following code and its output message > please.Does anyone know how to fix this? > #import <Foundation/Foundation.h> > @interface SayHello : NSObject > - (void)greet; > @end > @implementation SayHello > - (void)greet { > NSLog(@"Hello GnuStep"); > } > @end > int main(int argc, char *argv[]) { > NSLog(@"arrayCls = %@", objc_getClass("NSArray")); // Yes > NSLog(@"stringCls = %@", objc_getClass("NSString")); // Yes > > //! NSLog(@"userCls = %@", [SayHello class]); -- crash here! > NSLog(@"userCls = %@", objc_getClass("SayHello")); // null > > NSArray *nameList = [NSArray arrayWithObjects: > @"Scott", @"Jesse", @"Gaia", > nil > ]; > NSLog(@"nameList = %@", nameList); // good > NSArray *nameList2 = [[NSArray alloc] init]; > NSLog(@"nameList2 = %@", nameList2); // Ok > > SayHello *userObj = [[SayHello alloc] init]; // crash here! > NSLog(@"userObj = %@", userObj); > return 0; > } > 2023-07-16 21:02:02.665 abc[2996:4992] arrayCls = NSArray > 2023-07-16 21:02:02.665 abc[2996:4992] stringCls = NSString > 2023-07-16 21:02:02.665 abc[2996:4992] userCls = (null) > 2023-07-16 21:02:02.665 abc[2996:4992] nameList = (Scott, Jesse, Gaia) > 2023-07-16 21:02:02.665 abc[2996:4992] nameList2 = () > Process 2380 stopped > * thread #1, stop reason = Exception 0xc0000005 encountered at address > 0x7ffb73b91048: Access violation reading locatio > n 0x00000000 > frame #0: 0x00007ffb73b91048 objc.dll`objc_msgSend + 40 > objc.dll`objc_msgSend: > -> 0x7ffb73b91048 <+40>: movl (%r10), %r11d > 0x7ffb73b9104b <+43>: cmpl $0x8, %r11d > 0x7ffb73b9104f <+47>: je 0x7ffb73b91063 ; <+67> > 0x7ffb73b91051 <+49>: cmpl $0x0, %r11d > > > Thank you! >