Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C getValue

I have defined a class, POI.h:

@interface POI : NSObject

which is just a simple class that that has certain properties and a method defined as follows:

- (NSString *) getValue:(NSString *)key;

In my controller, when I try to log invocation of that method:

  NSLog(@"Name: %@", [poi getValue:@"name"]);

I get

Apple LLVM compiler 4.2 error Command
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
failed with exit code 254

Based on some previous SO answers, I figured out that error 254 when trying to log a return value from a void method. So I came to conclusion that the method my compiler is trying to invoke is actually

- (void)getValue:(void *)value;

defined in NSValue.h, which is of void type.

Now, I would really like to understand WHY this happens. Is my improper and foolish naming of the getValue method the only reason? How can I avoid it?

Actual error message:

LBSViewController.mm

  1. parser at end of file
  2. Code generation
  3. Running pass 'Function Pass Manager' on module '/Users/myuser/Documents/workspace/project1/Classes/LBSViewController.mm'.
  4. Running pass 'ARM Instruction Selection' on function '@"\01-[LBSViewController initializeLBS]"'

clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
Target: arm-apple-darwin12.5.0
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/y_/h89vdcjj7zs8s5zjh77x4h0h0000gn/T/LBSViewController-A4zhXy.mm
clang: note: diagnostic msg: /var/folders/y_/h89vdcjj7zs8s5zjh77x4h0h0000gn/T/LBSViewController-A4zhXy.sh
clang: note: diagnostic msg:

like image 934
Maggie Avatar asked Nov 24 '25 13:11

Maggie


1 Answers

This is a compiler crash and has nothing to do with how that code is written or how it might behave at runtime.

Follow the instructions and file a bug.

More likely than not, the crash is caused by either a garbage character in just the wrong spot or, even more likely, your syntax is so hosed somewhere else that it is causing the compiler to become unhinged.

Post the code for your initializeLBS method as that is what is triggering the crash (according to the compiler's error message).


Note that methods should not be prefixed with get. Won't cause the compiler to crash, but it is bad form.

See Key-Value Coding and NSDictionary for similar API patterns that you would likely want to follow.

like image 68
bbum Avatar answered Nov 26 '25 05:11

bbum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!