Maggie
Maggie

Reputation: 8081

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:

Upvotes: 3

Views: 1031

Answers (3)

user2967030
user2967030

Reputation: 13

press these buttons in order - shift ⌘ K - that may work, what you named the class probably has little or nothing to do with it, which is why I recommend that you clean it, it's good for your program anyways it's kind of like giving a massage to your program relieving it's stress or in the computers case any data hang ups :D

Upvotes: -5

bbum
bbum

Reputation: 162712

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.

Upvotes: 12

troppoli
troppoli

Reputation: 558

You question, is this because of the naming, yes it is. In both cases the selector to call boils down to: getValue:

There is no parameter type info at this level and no return type info. You're not allowed to overload functions based on parameter or return types in objective c.

Upvotes: -3

Related Questions