In Xcode Version 4.0 I notice that #pragma marks within methods are no longer showing up in the Jump Bar. The only #pragma marks that are showing up are those that are betwe
I'm also experiencing this problem. A pragma mark added before the first method will not show up. For example, this will not work:
@implementation RandomClass
#pragma mark - Getter Methods
- (void) firstMethod
{
}
@end
Here are some quick-dirty workarounds to make the pragma mark before the first method show up. You can add an empty block before it or you can just put the pragma mark inside the block itself.
Using an empty block:
@implementation RandomClass
{}
#pragma mark - Getter Methods
- (void) firstMethod
{
}
@end
Adding the pragma mark inside the empty block itself:
@implementation RandomClass
{
#pragma mark - Getter Methods
}
- (void) firstMethod
{
}
@end
It doesn't look too pretty but it works. I hope that helps.
To clarify the correct answer by RantriX…
If your first #pragma mark
fails to appear in the jump bar's context menu, add a pair of braces. (Xcode version 4)
For example, change this:
@implementation MainMenu
#pragma mark Lifecycle
to this (note the curly braces):
@implementation MainMenu
{
}
#pragma mark Lifecycle
@implementation ViewController
- (void)pragmaStartHack {} // Since pragma only works when after at least one method
#pragma mark This pragma will render in Xcode
// Your code here...
@end
I encountered the same problem. I now insert a dummy method after @implementation ...
and before the first 'real' method. I define this method in the project's ...-Prefic.pch
file so it does not show up in the Jump Bar.
Add the following to your ...-Prefix.pch:
#define PLEASE_LET_PRAGMA_MARK_WORK - (void) pleaseLetPragmaMarkWork {}
And insert the request in your omplementations:
@implementation anyClass
PLEASE_LET_PRAGMA_MARK_WORK
#pragma mark - This will show up.
Works like a charm.
Apparently there are some issues in the pragma parser in Xcode. In my case I could make the #pragma
s re-appear by unificating their syntax to the new one.
Instead of having not uniform and messy chunks of code with some pragmas in it:
// Code ...
#pragma mark -
#pragma mark UITextViewDelegate Protocol
// More code ...
# pragma mark - Important stuff
// Even more code ...
I changed everything to:
// Code ...
#pragma mark - UITextViewDelegate Protocol
// More code ...
# pragma mark - Important stuff
// Even more code ...
Basically, I made sure...
#pragma
line.-
.UPDATE
I've realized that sometimes above rules are not enough if the project is broken somewhere. ( I tried moving some sources to a new project and they showed correctly). So what I did is close my project, delete its derived data from the organizer and also delete these two folders
MyProject.xcodeproj/project.xcworkspace/
MyProject.xcodeproj/xcuserdata/
So next time I open my project Xcode will re-generate them :)
Now ALL my sources are OK again :)
For showing pragma marks in Jump Bar try this :