Objective-C: Trying to use Apple's MultipleDetailView - objective-c

I am working on trying to make a splitview based application. I am trying to use Apple's MultipleDetailView example code
http://developer.apple.com/library/ios/#samplecode/MultipleDetailViews/Introduction/Intro.html
I have never really used example code like this (I usually just atart from scratch). All i did was copy the code into the correct classes of my app, but when I try to run it on the simulator the app doesn't open.
I feel like I am maybe forgetting something obvious, since I didn't code it myself.
Thanks!

The usual debugging technique applies. Put a breakpoint somewhere early in the program -- the first line of main() for instance, and debug from there. Do you hit the breakpoint? If yes, move forward through the code until you find the line that causes the problem. If no, try to back up even further if you can, and also look for any clues as to what's going wrong. If the app is running at all, there should be some sort of error message in the console output.
"...the app doesn't open" doesn't tell us nearly enough to help you. Something like "the app delegate is instantiated, but it's window and splitViewController properties are nil" goes much further toward getting to the root of the problem.

Related

Xcode: "Spurious Update" console warning?

I'm writing a pretty straightforward ObjC app. (The only minor complexity is that it uses an external library called Chilkat for some basic networking, but I don't think that that's relevant.)
Occasionally, my project spontaneously pops up this warning message:
May 14 01:24:01 Neovenator-2.local Project[22645] : void
CGSUpdateManager::log() const: conn 0x4b29b: spurious update.
And I have no idea how to handle or even interpret it. There's nothing in my project called CGSUpdateManager, and my project doesn't call a log() function anywhere. I can't even reliably reproduce it, but it's popped up often enough to raise my interest level.
Searches at both Google and here for the term "spurious update" reveals a lightly scattered set of conversation, but nothing relevant to my project. Meanwhile, a Google search for "CGSUpdateManager" reveals it's something to do with Swift, which I'm not using at all.
Can anyone help me understand what this means? Or should I just disregard it?
Make sure to call super in viewDidLoad, viewWillAppear and viewWillDisappear.
Sorry, my code with correct Highlight/indentation:
- (void)setNeedsDisplay
{
//#if 1 //TEST (suppose we are only called by us)
if(wvImageRep_DoRebuild)
//#endif
[super setNeedsDisplay]; // "spurious update" ?
}
It's an example (#see my full response), it helped me

Debugging view controller transitions

Is there a symbolic breakpoint or something that will trap the following warnings, so that the erroneous code can be more easily found?
Attempt to present <> on <> while a presentation or dismiss is in progress.
Trying to dismiss the presentation controller while transitioning already. (<>)
I don't have a specific problem to solve, just looking for an answer to this question, which could just be "no".
When these errors occur, how do you find out the present/dismiss call causing the problem and/or the present/dismiss that is in progress?
Maybe a little more context would help us answer your question ?
Are you using UIViewControllerAnimatedTransitioning ?
When are you having this issue happening ?
If you want to debug, you can use UINavigationControllerDelegate method for your convenience :
- navigationController:willShowViewController:animated: or
navigationController:animationControllerForOperation:fromViewController:toViewController:
If you're not already using it for your animation.
The best I've found so far is to run with Allocations instrumentation and "Record reference counts".
Then you can find the specific instances referenced in the logs by their address.
This will have recorded the stack traces when that object was created, presented, etc, as they all involve changes in reference count.

Xcode error when ctrl-dragging image to new class

I already asked this in the Apple Dev Forum but received no replies, so I'll try here.
I'm unsure if this is a bug or whether I've missed something since I'm still very new to programming.
I have multiple view controllers and have made multiple classes. I have set the custom class "bit" of each view controller to the revelent class. When I ctrl-drag anything from the view to the relevent class header, I get the usual pop-up. I fill in the info, press connect, and BAM. It does the same kind of error whether I choose "Outlet" or "Action" It worked in the previous Xcode but I'm not sure if I've forgotten something.
The view controller and class that I added with Xcode 4 is still working beatifully.
I've tried adding the image manually but all that gave me was a SIGBART error just trying to get to the view. Again, I may have missed something, but I don't think there's much to miss is there?
Any help would be appreciated.
Just to eliminate a few things... I've deleted derived data, restarted Xcode and done a "clean". That's all I can remember that I've done.
Problem solved:
When selecting the implementation file. When I looked in the File Inspector, I found that under "Target Membership", the app name wasn't ticked. I ticked it and it now works well.
Since I didn't need to do that in Xcode 4, I suspect in Xcode 5, it doesn't do that automatically. Maybe that's a bug? I don't know if it was deliberate by Apple, but I think I'll file a bug report anyway since It's a bit of a nuisance.

GLKBaseEffect prepareToDraw GL ERROR: 0x0501

So ive been doing some iphone development with some OpenglES in it, but i am getting a rather weird error when i call prepareToDraw on my effect. My program in short simulates dice rolling (trying to learn objective-c and opengl). The program works fine for the most part, i can use everything ive programmed my app to do (with its bugs in the physics but ill fix that later). The problem comes in after ive used the part that contains the OpenGL.
The program contains 2 menu's you have to go through in order to reach the screen that is using OpenGL, once you have used the apps OpenGL part and go back to the previous menu, then try go back to the OpenGL part again, i get a print out saying GL ERROR: 0x0501. ive narrowed it down to be caused by the prepareToDraw method from my effect. The other weird part about it, is if i go back, then forward again, the OpenGL works again, and can be repeated again and again for it to be working and breaking every second time you go into the OpenGL part.
I've been searching around for similar problems to mine, but each time its got something to do with loading textures that are not a power-of-two texture, which doesnt help me because im not even using textures yet, just colored vertices.
ive pastebin'd my two code files where the problem should lie
Dice.m: http://pastebin.com/ze1DEEzs
in the draw method you'll see my printouts have narrowed down where the problem lies, which is the prepareToDraw method. (line 308)
RollViewController.m: http://pastebin.com/VycwAh3R
this file is where i setup the effect and the context etc, so i must be doing something wrong in here to cause the prepareToDraw method to mess up every 2nd time i run the OpenGL part of the program. i have a feeling it has something to do with not letting go some kind of resource to do with the context and the effect, but i cant find anything about deleting context and effect (probably because you dont need to but im not sure).
I hope there is someone out there that has run into the same problem and can answer my question and i hope its not just a silly mistake because ive been trying to solve this for a while now :)
thanks
After much pain and suffering i finally found a fix to the problem. Im not exactly sure why this is a problem, but creating the context within the OpenGL part (aka RollViewController.m) is not the way to do it. Instead you should create it once throughout the lifetime of your program and just set your current context for your glkview to be the context you have made. Maybe someone can enlighten me why recreating the context is a bad idea.
In my code i have a profile object that gets passed around between views and menu's so that they can all communicate with the same data, so i just defined a public context within my profile object so that everything can get access to the context instead of creating their own (and breaking).
The error seems general and might be because of different issues. I avoided it(for now) by not using mipmaps. I commented the following code I had and don't have the error anymore.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glGenerateMipmap(GL_TEXTURE_2D)

EXC_BAD_ACCESS on animationForKey:

I'm trying to use a recent feature of the Scintilla component, which provides OSX-like text-highlighting effect (the yellow animated bouncing box), and I'm stuck with an error that pops up intermittently :
EXC_BAD_ACCESS
pointing to this particular line :
if (layerFindIndicator!=nil)
if ([layerFindIndicator animationForKey:#"animateFound"])
[layerFindIndicator removeAnimationForKey:#"animateFound"];
(the ifs are mine; just in case I caught the object layerFindIndicator being nil, or deallocated or whatever... Unfortunately, it doesn't help...)
layerFindIndicator is seemingly a subclass of CAGradientLayer. (You may see the full code for layerFindIndicator, here).
Since, I'm an absolute newbie to Quartz Core, could please give me any hint as to HOW this could be debugged?
Since, I'm an absolute newbie to Quartz Core, could please give me any hint as to HOW this could be debugged?
This doesn't have anything to do with QuartzCore specifically (at least, I hope not)—it's general this-object-has-been-killed-before-its-time-how-do-I-find-the-killer stuff.
In Xcode:
Edit your current scheme.
For the Profile action, set it to use the Debug build configuration.
Dismiss that and then hit the Profile command.
Xcode will build for that action and then launch Instruments.
Instruments will prompt you to choose a template; you want the Zombies template. Once you've chosen it, Instruments will create a trace document and run your application. Switch to your application (if it isn't already frontmost), then do whatever causes the crash.
If the crash really is a dead-object crash, Zombies will reveal it. You'll get a flag in Instruments's timeline saying something like “message sent to zombie object 0xd3c2b1a0”, and your program will probably exit shortly thereafter.
In that flag is a tiny little button that looks like this: ➲ except it'll be gray. Click on it.
That takes you to the history of that object (actually of that address, including any previous objects or other allocations that have started at that address). Show your Extended Detail Pane (the one that appears on the right showing a stack trace), then scroll down to the end and then move backward (upward) step by step through time, looking at releases and autoreleases, looking for the one that isn't balancing out the object's allocation or a retain.
The solution will probably involve one or more of:
Changing a property to be strong or weak rather than assign/unsafe_unretained
Adding a property where you previously did not strongly own an object
Rearchitecting some things, if it's not clear which of the above you need to do or if either one of them seems like a filthy hack
Switching to ARC to get weak properties and __weak instance variables (both of which get set to nil automatically when the referenced object dies) and to get local variables being implicitly initialized to nil
But it'll depend on what you find in Instruments. And, of course, there's the chance that your problem—the bad access—isn't a dead object at all and all of the above will not help you.
Try this:
if (layerFindIndicator!=nil){
if ([layerFindIndicator animationForKey:#"animateFound"]){
[layerFindIndicator removeAnimationForKey:#"animateFound"];
}
}
Also check to see if it is released else were.
EDIT:
Another thing I found was you didn't have an white space in the if. Your code should now look like this:
if (layerFindIndicator != nil){
if ([layerFindIndicator animationForKey:#"animateFound"]){
[layerFindIndicator removeAnimationForKey:#"animateFound"];
}
}