I used a tutorial that I found previously mentioned on stackoverflow, however I am running into an issue when I try to incorporate the code into a Storyboard I've created.
My storyboard is setup as follows:
Navigation Controller -> Table View Controller (static content) -> Table View Controller (where the XML should appear)
I get the following compiler error when I use the simulator and go to the Table View Controller where the XML should get output to:
unrecognized selector sent to instance 0x6b5f300
From what I gather, the problem is with the Table View Controller that I have setup. I specify its class to point to the custom viewcontroller implementation files I've created, where all of the code is from the tutorial.
I've gone through every one of the tutorial files line by line to make sure I've used them properly in my own project and they all match. I have to believe the issue is a difference between the old-style of .xib files the tutorial uses and the new style of using the storyboard to layout the app. I even made sure the tutorial code compiles and works properly in my struggle to figure out what I'm doing wrong here.
Should I be creating a different type of view controller for the XML code to be displayed on versus using the drag-n-drop table view controller object the storyboard provides?
unrecognized selector sent to instance 0x6b5f300
This means that you're sending a message to an object that doesn't understand that message. You may have forgotten to implement some method that you're calling, or you may have an object of a different type than what you expect. Occasionally, it can also mean that you've got a bad pointer, i.e. there just happens to be a new object located at the same address that was previously used for some other object.
Take a look at the object at 0x6b5f300. What type of object is it? What message are you sending to it? Answering these questions should get you a lot closer to an answer.
Related
I'm trying to make a category for a class that gets defined in a source file I don't have access to, namely RunnerViewController.
The two important files here are iPad_RunnerAppDelegate.h and FilesBrowser.mm. I do not have access to the header file's corresponding source file.
iPad_RunnerAppDelegate.h contains a forward declaration to the RunnerViewController class, and can reference that class with no difficulties.
However, if I try to #include "iPad_RunnerAppDelegate.h" in FilesBrowser.mm and then try to create a category in the same file, it doesn't recognise the class name.
Despite this error appearing, I can still use the RunnerViewController class inside FilesBrowser.mm, I just can't make categories for it.
What's happening here, and how would I fix it?
I've had to do this same thing but it was a long time ago. The problem is that without some indication of where to apply the category, your code cannot work alone. What you need is info to the compiler to let it know where it's going to insert the category.
In FilesBrowser.mm, you will tell it by adding this BEFORE "iPad_RunnerAppDelegate.h":
#interface RunnerViewController: UIViewController // or whatever it actually subclasses
#end
Now the compiler knows that its going to insert the category against an Objective C class named RunnerViewController.
But - you're not completely done. Now you need to insure that the runtime / loader do the class loading and category insertions at the proper time. This is where my knowledge gets a bit fuzzy, so it may not turn out to be a problem at all.
What I believe needs to occur is for the RunnerViewController class to get loaded first, then later at some point the category you wrote applied to it (but this may not be necessary). So if RunnerViewController is statically linked into your app (using a .a archive), then you're good for sure. But if that class is in a dylib loaded dynamically, and your category is statically linked - well that might be a problem. I just don't know how long Apple waits to try and deal with the categories (which by the way the -ObjC link flag is for.
In any case try the code above first and just see what happens. If RunnerViewController is dynamically loaded, and you get some hard runtime error, there is a workaround where you would make your category go into a module/framework that is also dynamically linked, but gets linked after RunnerViewController.
In the end I believe you have a good chance of making this happen.
I am new to Xcode so I didn't get how to resolve this error by reading other articles in StackOverflow related to this. Basically I am working on the CoreData part and the following code accesses Amount, Bank Name and Title field but it's giving this error.
The first four lines in your code are outside any context. You can't do that. No executable code can appear except inside a function — usually, some method of some class.
So those four lines need to be inside the ViewController class, not before it, and again, not just loose inside it, but in some method of the ViewController class.
I'm new to Xcode.I'm trying to figure out how to use showViewController.My question is how to call the UIViewController that to display ? via name or a identifier? And where can I find them ? In addition, the document says The default implementation of this method calls the targetViewControllerForAction:sender: method to locate an object in the view controller hierarchy that overrides this method,what does it mean? Should I call targetViewControllerForAction:sender:fist when using showViewController?
showViewController behavior basically depends on context you're app is in.
But calling it is really simple. All you need is reference to your UIViewController object(or it's subclass).
You can do it in couple of different ways:
If you're using Storyboards, give your storyboard view controller identifier, and use API call: UIStoryboard(name, bundle).instantiateViewControllerWithIdentifier(identifier). This gives you UIViewController that you should pass as an argument to showViewController. You could find information about API here: https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIStoryboard_Class/index.html#//apple_ref/doc/uid/TP40010909-CH1-SW6
Also, you could get your UIVIewController instance directly constructing it using proper initializer.
So: not worry about this targetViewController method, just get your object (initialize it via constructor or get it from storyboard), and pass it to show method.
In case you have further questions - feel free to ask.
I have a very general table view.
when it is refreshed, it will go to fetch list of objects from Parse. Analyze these data in a dispatch_async queue, then refresh table view. Most time, it has no problem, but some time reloadData() crash
Is it crashes because the tableView is reloading data when I call it? (when the tableview is init, reloadData may be called automatically) How to avoid this error? ( there is no error message in console )
EDIT:
I tries to put ?, but does not work
This happens when your tableView (or whatever object you're sending the message to) is nil. So sometime before your async call dispatched this on the main queue, your tableView got dealloacted.
Check this link out for some info:
http://www.touch-code-magazine.com/how-to-debug-exc_bad_access/
You will get EXC_BAD_ACCESS error mostly in the following scenarios:
You are trying to access an object that is not initialized.
You are trying to access an object that no longer exists. Either it’s being released or it’s nil. In ARC mode, make sure you take ownership of the object that you want to use.
You are passing an message to an object that the object doesn’t understand.
It can also happen for bad typecast. Like the lines below where I am trying to access an int with %# in stead of %d.
int myAwesomeInt = 9;
NSLog(#"%#", myAwesomeInt);
How to debug:
Identify what you did that caused the crash. Did it crash while view of a particular view controller didLoad or in a delegate method or on a particular action. That will often help to find the object that is casuing the error.
(In your case look at what specifically happens when you are reloading the table. Do a stack trace line by line and see what your code is doing during a reload)
Most of the time “NSZombies” can help to identify the dead object. You can enable NSZombies by editing your scheme Product -> Edit Scheme -> Diagnostics.
If you still don’t find the root cause then always go backwards from child view controller to parent view controller to see what object needs to be retained or what message needs to be passed properly.
Look into Static Analyzer and Instruments for advanced debugging.
Credit:
The Basic Troubleshooting guide
Hope this helps. Good Luck
I have checked recent header files for PSListController , PSViewController and PSBaseView, but there is no method for acknowledgement of view creation, like iOS has viewDidLoad - Although there are many methods available for view Display. One I found is: -(id)initForContentSize:(CGSize)contentSize, but I don't want to use it as I don't think it would be appropriate to do so.
So which method should I choose in order to initialize my instance variables or do other stuff? Thanks.
Note: I am using rpetrich's Header Files.
Some of those headers are slightly older on the repository but looking at an iOS 7 version of PSViewController you will see that it is a subclass of UIViewController. UIViewController does contain viewDidLoad so PSListViewController "should" contain the same.
Source: http://www.developer.limneos.net/?framework=Preferences.framework&header=PSViewController.h