iPhone app: "Parse issue - expected ';' after #synthesize" - iphone

I'm working on an iPhone app and got this strange things happening.
I have a property declared in my .h file:
BOOL shouldProcessVenueListRequest;
#property(nonatomic, assign) BOOL shouldProcessVenueListRequest;
So far, so good. Then in my implementation .m file:
#synthesize shouldProcessVenueListRequest;
This works perfectly well for about 20 other properties, but for this one, I'm getting an error in the implementation: "Parse Issue - Expected ';' after #synthesize" - and the error pointer is in the middle of the variable name - see the image.
I tried removing and re-adding this property manually; tried copy/paste variable name from .h - nothing worked. I'm totally confused about this now. Any help is greatly appreciated.

Thanks to all who replied. It turned out to be an issue with the XCode rather than anything wrong with my code. Apparently, when I was typing the code in, I was interrupted half-way into typing, so that error message was valid (at the time). Then, about an hour later I came back to it and completed typing - but for some reason XCode was stuck on this error message.
I did 'clean', then 'build' - didn't help. So I did 'clean' again and then closed project. When I reopened the project and did 'build' again - the error wasn't there any more.

Strange problem. Try the following:
Try another name for your property (maybe it is a keyword/name used elsewhere, namely in any of Apple's framwork or similar - you could try command-clic on the word to see if Xcode finds its definition anywhere else than in your header file maybe?)
Be sure there is no hidden (non-printable) character
Try another place for your #synthesize, moving it one or two lines below, to check if the error comes from this very property or the one above it
[EDIT] Did't see this in your screenshot the first time, but it seems you have a semicolon right in the middle of your #synthesize shouldProcessVenueListRequ;est;, between the 'qu' and the 'est'... or is it the Fix-it proposition?

Check your code to ensure a few things
There is no space between shouldProcessVenueListRequ and est (even I thought you had a ; in there between the two parts :)
If you are copy-pasting the variable name from some place, you might want to type it all out manually (as Ali suggests, there might be a hidden character)
Try doing a clean-build

Even I got the same problem. When I checked it out, I gave the same name for variables but in different files. I just gave different names for all the variables, like if I have used a variable coupon in more than one file, I made it one as couponDisplay in one and couponList as another.

Related

Marmalade IwUIController causes crash when accessing IwUIElement objects

I created an app that works which is similar to the examples from the Marmalade SDK. Then I tried to move the IwUIController derived class in a separate files .h/.cpp to clean the code up a bit but I get a crash every time I try to access any IwUIElement? For example:
CIwUIImage* image = IwSafeCast<CIwUIImage*>(pScreen->GetChildNamed("Image"));
pScreen is declared as
static CIwUIElement *pScreen;
and then in main(): pScreen = CIwUIElement::CreateFromResource("Screen");
What can be the reason for these crashes? Does the Controller class need to be in the same file as main()? I've tried to debug and the pointer appears to be passed properly.
Not sure it really counts as an answer, but I don't have enough stackoverflow reputation to comment apparently;-)
If you've got C++ code that worked OK until you split it into two files, I would seriously check the #include and other declarations are the same in the new two files as they were in the originals. 9 times out of 10, my experience is that for some reason something is not the same. Actually one specific issue worth checking for is that a struct or class is only partly declared (e.g. a forward declaration) in one file and has lost its parent.
Having said that, as Creator, said what were the symptoms of the crash? Is this possibly the dynamic cast failing of IwSafeCast failing?

prefix attribute must be followed by an interface or protocol + NSManagedObject Subclass

So I get the compile error "prefix attribute must be followed by an interface or protocol" in an xcode generated NS Managed Object subclass. The error is matched to the line #class AnswerSet, Section, SurveyStyle; and then all lines where these objects are used. The error seemed to have come at random but I am fairly convinced it originated from deleting some of the generated classes and then re-building them.
The code in the class is irrelevant as it worked before and compiles when I copy it into a new project.
So far I have tried deleting them all again and rebuilding. Cleaning the project. Restarting ect.
My last resort will be to copy everything across into a new project file and/or refactor what I have but I'm hoping someone can suggest something to save me from that!
Edit: Just attempted to rename the entity/class of the offending file. Xcode hanged and I force quit it. Renamed the file and refactored. Ended up with the same issue.
Turns out the error was a result of a stray character outside the comments at the top of a class. Not sure why it didnt pick it up but it took a long time to track it down!
Add The piece of code in implementation file(.m)import
AVFoundation/AVFoundation.h

Suppress warning: Meta method xx in category from xx conflicts with same method from another category

How can I suppress this compiler warning:
Meta method 'prefix' in category from '...soap+prefix.o' conflicts with same method from another category ?
here is the category soap+Prefix.h:
#interface Soap (Prefix)
+(NSString*)prefix;
#end
and soap+prefix.m:
#import "Soap.h"
#import "Soap+Prefix.h"
#implementation Soap (Prefix)
+(NSString*)prefix { return #"EInspector"; }
#end
and these two files by the way are automatically generated with SudZc wrapper for web services.
p.s. this warning is issued ONLY in XCode 4.4
thank you so much in advance.
This happened to me when I have accidentally imported an implementation file of a category (.m) instead a header file (.h).
Somewhere else in your project, +[Soap prefix] is being declared in a category. Try searching your project for other declarations of +prefix.
Another possibility is that during a large refactoring or complex merge of your project.pbxproj file, the project ended up with two references or copies of the same file, and both are being compiled. I've seen it happen, and these sorts of warnings or errors are usually what happens. Try searching in the Finder for other files with the same name to see if you have a duplicate file somewhere.
In my case the issue was due to a wrong merge of project.pbxproj (so similar to Nick Forge's case), which caused too many references to the same file (however the file was physically only once on disk). When I removed redundant references the warning stopped appearing.
You should reference a great answer by someone who also posted something similar:
Is there a way to suppress warnings in Xcode?
In my opinion the 2nd (highest voted) option is the best!

conflicting distributed object modifiers on return type in implementation of 'release' in Singleton class

I have recently upgraded to Xcode 4.2 and its started to give me so many semantic warnings with my code...
one of them is "conflicting distributed object modifiers on return type in implementation of 'release'" in my singleton class..
I read somewhere about - (oneway void)release; to release this warning but once i put that in my code i start to getting compile error as "Duplicate declaration of release" not sure why and if you try to find the second declaration it shows in this line
SYNTHESIZE_SINGLETON_FOR_CLASS(GlobalClass);
Update: This is the post where it explained about - (oneway void)release;
how to get rid of this warning "conflicting distributed object modifiers on return type in implementation of release" ? and why its happening ?
The post you link to contains the solution to the problem in the title and explains why it happened to you.
However, from reading your question it appears that your new issue is caused by mis-applying the great advice in that post's answer. I am fairly certain you added the line
- (oneway void) release {}
in your .m file rather than amending your existing
- (void) release {
line with the extra word "oneway".
This would be why you get "Duplicate declaration of release". Yes, this is confusing because it's a duplicate definition that is invisibly creating the duplicate declaration. But I've just tried doing it your wrong way, and I get that "duplicate declaration" message.
I get the impression, perhaps wrongly, that you didn't realise you actually had a release method, particularly when you think adding the line will "release this warning".
Don't take all errors too literally, and always try to think what someone might really mean as it's often different from what they say, but do try and understand what is in your code, even in the classes you've taken off the shelf.
And to address other questions raised, the reason you're overriding release is because it is a singleton which is not usually released. You probably only have a definition in your code, which will suffice.
What Jonathan Grynspan has to say about specifying on both the declaration and the definition is broadly valid (and indeed the root of the issue) but it's important to recognise that in this specific case, the declaration is by Apple's foundation code which has changed.
So, if it's not clear already, amend the line that XCode finds problem with to include the word oneway.

Objective-C error: expected '=', ',', ';', 'asm' or '__attribute__' before 'class'

I'm getting this from an iPhone app I'm working on. Not sure how to interpret the error... It's thrown at a few place in my code. I can't see any pattern of occurrence.
Is this a generic error? What's the meaning of it?
The error you posted indicates that you have a syntax error around your use of class. Manually inspect the first location the error is reported, and you might notice the cause.
To help you debug further, please include the surrounding code so we can better help you.
Most common causes:
Missed # in #class for forward class declaration in headers
Missed ; after the declaration of an enum, a structure, or a typedef
Copied C++ code, where class is used to declare a structure, but code is invalid in Objective-C
I've just solved this exact same problem and I have been tearing my hair out over it.
GCC wasn't highlighting the problem in the header file where the error actually occurred - I had a stray 'B' character at the bottom of a header file (from running command-B to compile). The error was then being thrown in the .m file and other .h files which included the problematic one, often at the #class statement.
If it's throwing an issue with your #class statement, the problem is almost definitely in one of the preceding header files, as you include them directly beforehand - try commenting these out one-by-one and recompiling to find out which. Once you find the culprit file, finding the actual error will be much easier.
Same as Ronan except this time I had a stray character in a source file just before I started importing headers (similarly it was an 's' for Command-S). This particularly threw me since the error message was associated with a library header file that I had never touched and the app was working fine for weeks before that. So if you are getting these errors associated with header files that appear to be fine and that you haven't touched look around for something like this.