Xcode 4.3.3 indentation broken - xcode

Automatic indentation in my Xcode sometimes comes out wrong. I can't see any rhyme or reason to when it is correct and when it isn't. Here is a typical case where Xcode got it wrong. Selecting and asking Xcode to re-indent does not help. Of course I can fix it manually. But it would be much better to fix whatever is wrong with my Xcode.
Any successful experiences out there?
-(UIFont*) font {
UIFont* actual = self.actualFont;
if (actual) {
return actual;
}
WJStyleSheet* sheet = self.styleSheet;
UIFont* r = sheet.font;
return r;
}

Does code completion still work completely. Can you for example type self.actual and then hit CTRL + SPACE and get a coloured code completion suggestion with the class next to actualFont? If not then I think this is related to the code completion which can get corrupted in Xcode.
I could fix this using the following answer: https://stackoverflow.com/a/8165886/784318

Related

XCode 7.3 bug with code marking (in Swift)

In XCode 7.3, document items (toggled with ctrl-6) is not displaying properly beyond a certain point. (There is nothing wrong above the screen shot)
Not many people will experience this since it happens (as far as I've found out) in specific situations.
let i = 0
switch i {
default: "\(i) ©"
}
Copy and pasting the above code will make the same thing happen in any file with // MARK: // FIXME: // TODO: code markings.
The condition for this to happen is the combination of the three:
Using switch: if {} won't cause the same problem.
Using string interpolation: String(format: "%d ©", i) or "stringText ©" won't cause the same problem.
Using Emoji & Symbols with a space in front: "\(i)©" won't cause the same problem.
Any one of the three conditions are not met, the bug won't happen. So in case you look at document items a lot and don't want to see the mangled dropdown list, try changing any one of three conditions.

CGContextSaveGState: invalid context 0x0 (Xcode 7 GM)

I have this problem after I compiled my code with Xcode 7 GM.
According to Apple this is a bug, but it still seems to be an issue. Everything works fine, but is it possible to get rid of these errors?
: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Someone in other forums said something about status bar, but I don't have any success to eliminate the message. This is not a huge issue, but it's a useless "error". I'm using Interface Builder.
Updated: I used Objective-C if you use Swift, maybe this is the question you're looking for
This also happens for me on 7 GM, but removing UIViewControllerBasedStatusBarAppearance from Info.plist fixed it for me, as said here.
Update: Warning seems to be gone with iOS 9.2
I'm drawing using UIBezierPath
Removing path.fill() removed the warning.
I have found another cause for this error today.
When I wrote some drawing code in my View Controller class, these errors appeared. I realized that I have to create a UIView subclass and do the drawing steps in the override drawRect function. When I moved the drawing code there, all the errors disappeared.
This is a good case to use the debugger. I set a breakpoint in my main and then used the F7 key to step through the code until the warning appeared. Turns out, there's yet another way this bogus error appears:
NSColor *myColor = colorFromRGBA(43,51,59,0.95);
[myColor set];
(self.window).backgroundColor = myColor;
It was generating the warning on [myColor set]. Evidently, I didn't need this and commented it out. At that point, the error went away. Your experience may differ, of course.
UIGraphicsPushContext, UIGraphicsPopContext worked for me
class CustomLayer: CAShapeLayer {
override func draw(in context: CGContext) {
UIGraphicsPushContext(context)
...Your code here...
UIGraphicsPopContext()
}
}
Similar to what Ayman Ibrahim said,
I commented out two lines and it worked like a charm.
bezier2Path.close()
// color.setFill()
// bezier2Path.fill()
Restart the device. It fixed my problem.

Show ViewController on Extension info button Edit Mode

I am working on an Today Extension for Yosemite.
I would like to show a SettingsViewController instead of going into edit mode.
If I "presentViewControllerInWidget" on "widgetDidBeginEditing" it gets some weird glitches and the view controller is hiding and showing all the time.
Did anyone achieved to show an viewController on info button click or knows a workaround on that glitch?
func widgetDidBeginEditing() {
self.presentViewControllerInWidget(self.settingsViewController)
}
This worked for me:
func widgetDidBeginEditing() {
var delay = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(delay, dispatch_get_main_queue()) {
self.presentViewControllerInWidget(self.settingsViewController)
}
}
I guess this is a bug that made it into the Yosemite release.
Documentation on widgets is very sketchy at best and it seems there are quite a few oddities in the framework.
When adding a symbolic breakpoint to widgetDidBeginEditing I get two hits when clicking the little edit button, and the edit Button becomes "Cancel". It is supposed to say "Done" though. Only after an "Add" action should it say "Cancel" (Just check out Apple's Weather widget)
Important to say: I am not using the template with the NCWidgetListViewController but my own list implementation.
If anyone finds a proper solution to this problem I'd be very happy!

Why does Xcode autocomplete fail to work when I alloc/init a variable?

I have a ridiculous problem with Xcode 4.3.2. Whenever I declare a new variable say
NSMutableDictionary *var = [NSMutableDictionary alloc] init];, Xcode autocompletes NSMutableArray in LHS of the expression but not in RHS.
This is irritating obviously. Often causes typos which I have to re-correct going back and certainly hampers the flow. From my experience it doesn't happen in any other situation.
Anyone else ever faced this? Should I raise a bug?
I think that's because Xcode doesn't know if you want to make some operation with the class and tries to find an appropriate variable. So if you want Xcode to autocomplete your class name in RHS, first write [] then start typing inside: [NS...]

Fix for Xcode's indiscernible highlighting of inline errors?

I can't be the only one that finds Xcode's method of "pointing out" where your mistakes are - ridiculous. As helpful and essential as the feature is.. it does not help to make the line I need to fix virtually impossible to read or edit... let alone see...
And don't get me started on the constant struggle to find a "selection" color that is visible, yet retains one's sanity/ability to see what the selected text actually IS!
What am I missing here? I know how to futz with the colors in xCode, I know how to mess with the Appearance "Control Panel", but it all just results in different configurations - of varying aesthetic quality - that are all hard to read... I don't have this issue in TextMate... Is that my answer?
UPDATE: Thanks to the brilliant work, and answer by #amadillu, here is what the remarkably more usable Xcode looks like after installing his Xcode 4 "Fix-Ins"
I've made an Xcode Plugin by using davekeck's "fixins" that allows you to customize the colors of the inline error and warning messages. This really helps if you use a dark scheme / background . See here.

Resources