CGContextSaveGState: invalid context 0x0 (Xcode 7 GM) - xcode

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.

Related

What does "invalid mode 'kCFRunLoopCommonModes' ..."mean?

Environment: Version 11.0 beta 3 (11M362v)
Here's the full text:
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug.
This message will only appear once per execution.
Hello World
This message only appears when I click on a UISwitch button that is connected to an action; here, printing "Hello World".
Apparently the behavior of the action isn't affected.
As a comparison, I've created a UIBarButtonItem in the toolbar which behaves normally. So there's something fishy about the switch button.
Question: why would this appear and what does it mean? Remedy?
I think it's a warning that Apple should fix it itself. Even in this sample project which is from WWDC19 this problem exists. There is a UISwitch in a cell of a table. When I tap it, the mentioned warning is raised.
So, in my view, it is a bug that Apple should deal with.
Judging from the replies by Apple Developer Relations to this post, this is a bug in UIKit and one that Apple is tracking. Until the bug is fixed, the advice is to treat this as "log noise".
I had a similar problem:
When I got the call-back from the UISwitch, I reloaded the UITableView.
I think that the call-back is initiated before the UISwitch finishes changing its context, and reloading the cell in that state creates some conflict.
With that theory, I solved my problem like so:
I separated the cells into sections, where the cell with the UISwitch was in its own section.
When I got the call-back from the UISwitch, I reloaded all the sections except the section that has the cell with the UISwitch.

AutoLayout debugger shows (null) ((null), (null)) for constraints with no useful information

I am working with AutoLayout and am using a library called FLKAutoLayout. When I have a conflict the autolayout debug messages that I am used to do not always show useful information about the constraints in conflict.
Has anyone seen this before and know how to resolve these messages?
From taking a look at FLKAutoLayout it looks like your problem is with this line in NSLayoutConstraint+FLKAutoLayoutDebug.m :
`return [description stringByAppendingFormat:#" %# (%#, %#)", asciiArtDescription, [self.firstItem flk_nameTag], [self.secondItem flk_nameTag]];`
asciiArtDescription is a private method on NSLayoutConstraint, while flk_nameTag is an property added as an "associated object".
Are you working in Swift? It could be something interfering with the program's ability to do those two things, even though it's in objective-C code. You could try creating a test project in Objective C that recreates the warnings to see if they appear.

dequeueReusableCellWithIdentifier never returns

When I call dequeueReusableCellWithIdentifier it is freezing my code and does never return any cell (or nil) I change the code from my custom class to a UITableViewCell to be sure the problem wasn't in my class, I also create a brand new empty cell to call with the identifier.
I add a log before and after the call for dequeueReusableCellWithIdentifier as you can see in the screenshot the one before gets called once and the one after never.
I try to clean and build, clean the project folder, delete DerivedData, restart the computer. I can't see any exceptions or what is really holding the code.
Any suggestions?
I am not sure what happened to XCode, but, if someone find the same problem here is what I had to do.
I didn't find anything wrong with the cell (yes I was using storyboard and the identifier was set correctly) and noting was wrong with the code in the custom class as well. I even went to the point of create a secondary custom class and custom cell and it did not help, so I try to put a invalid identifier and even there XCode did not return me an error (as it should).
I had to delete my custom cell from the storyboard, as soon as I did that all start to work again, first the error that the identifier didn't exist, than the temporary one start to work, than I recreate the original one (exactly as before) and all start to work again.
Very overkill but worked for me. Thanks for all the help!
It is expressed that you are printing println("return dequeueReusableCellWithIdentifier"), but can't see your return cell code at the end of your function, that must conform to your function expectation.

Xcode 4.3.3 indentation broken

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

My program crashes due to SIGABRT?

2012-05-31 00:17:51.384 SAMPLEGAME[2901:10703] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SAMPLEGAMEViewController 0x752c140> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key girlHeadView.'
*** First throw call stack:
(0x1460022 0x1a7dcd6 0x145fee1 0xe47022 0xdb8f6b 0xdb8edb 0xdd3d50 0x6bb71a 0x1461dea 0x13cb7f1 0x6ba26e 0x5601fc 0x560779 0x56099b 0x4bf401 0x4bf670 0x4bf836 0x4c672a 0x497596 0x498274 0x4a7183 0x4a7c38 0x49b634 0x3aa1ef5 0x1434195 0x1398ff2 0x13978da 0x1396d84 0x1396c9b 0x497c65 0x499626 0x21fd 0x2165)
terminate called throwing an exception(lldb)
Hi everyone,
I am new to iOS programming and am lost on something.
I renamed my original UIIMAGEVIEW from "yelOrb"... which was inefficient for the real object in the end replacing a yellow orb. So I renamed it to "girlHeadView". (Mind you, this is what I named the UIImageView that you control with arrow keys.)
Now whenever I run the program I get a stink in' SIGABRT telling me this [in the code above].
I even renamed "girlHeadView" back to "yelOrb".
I went through my .h & .m file, no stray word or incorrect spelling is causing this.
How am I able to fix this? I just implemented a button function to change the UIImageView (I even commented it all out to see if that caused it- still SIGABRT issue) and I can't even run the simulator.
Thank you!
Edit: Found my problem, I had to remove and re-add the yelOrb's image on the storyboard. Odd, but it worked. :)
It sounds like there's an outlet in interface builder connecting the UIImageView to the old property name, yelOrb. Then, when the view controller's view loads, it tries to make that connection to yelOrb which no longer exists, so you get that error.

Resources