How to (Using Storyboard) create JSON Parser in iPhone? - iphone

Currently I am working in iPhone application, Using Storyboard to create JSONParser, Import JSON Library inside the application, then I have add #import JSON/JSON.h inside ViewController.h file, but the error comes in "file not found", and JSON Framework classes error in release because I am using RFC, so how to fix these issues?
Inside JSON Framework classes error found here

Your project uses ARC, but the JSON library doesn't. You need to disable ARC for the library files. To find out how, see this question:
How can I disable ARC for a single file in a project?, or this one: ios5 ARC what is the compiler flag to exclude a file from ARC?

the error you are getting is ARC issue. your project is ARC enabled , but the JSON framework is not using ARC.
you can disable the ARC in your whole project, or use it for single file . see

Related

Why am I able to use MessageUI without a framework reference?

In my Swift 2 project, targeting iOS 9.2 and above, in Xcode 8.2.1, I have code that shows the mail-compose screen like so:
if MFMailComposeViewController.canSendMail() {
let composeMailVC = MFMailComposeViewController()
composeMailVC.mailComposeDelegate = self
composeMailVC.setSubject("Test")
// etc
}
Originally I had a reference to the MessageUI.framework in my project properties, but after removing the framework reference and cleaning the project, it still builds fine and when I run the code on my device the mail compose window still appears and seems fully functional.
I cannot find any explicit references to MessageUI.framework in the raw text of my .xcodeproj file, nor is there anything in my Objective-C bridging header.
I know that Swift does make some implicit framework references, but I couldn't find anything that suggests MessageUI.framework is one of them.
Curiously when I jump to the definition of MFMailComposeViewController XCode shows it in the MessageUI module.
The compiler automatically added the frame work in given its previous direction - IE. Import.

use swift file into Objective-C project

Can anyone tell me how can I use swift file into my objective-C project?
I have a swift file which inherits from UIViewController instead of NSObject. I am trying to use the swift file but I am not able to figure out how.
When I add my swift file into objective-C project, it usually asks to create a bridging header.
In that header file I am importing my swift file as -
#import "SlideController.swift"
and my bridging file name is objcToSwift-Bridging-Header.h
I read many answers which asks to import file
#import "MyProductModuleName-Swift.h"
into the .m file, but I can't find any such file in my project.
I also changed the defines module = YES as shown in another answer.
But still I am not able to access swift file.
What am I missing? Please tell me the right steps to figure it out.
After you created Bridging header.
Go to Build Setting =>Search for "Objective-C Bridging Header"
Just below you will find ""Objective-C Generated Interface Header Name" file
and import That file in your view controller.
ex.In my case: "Dauble-Swift.h"

ARC Semantic Issue: No visible #interface for Class declares the selector

Pretty basic stuff but i am unable to troubleshoot where the problem is. In my project, i have a class named "TheFeedStore" with following two methods:
- (BOOL)hasItemBeenRead:(RSSItem *)item
{
............
}
- (void)markItemAsRead:(RSSItem *)item
{
.........
}
I am using the following class method so other classes can access these methods using it:
+ (TheFeedStore *) sharedStore
{
static TheFeedStore *feedStore = nil;
if (!feedStore) {
feedStore = [[TheFeedStore alloc] init];
}
return feedStore;
}
In one of my another class, i can easily access the above methods by writing
if ([[TheFeedStore sharedStore] hasItemBeenRead:item])
or
[[TheFeedStore sharedStore] markItemAsRead:entry];
But in another class if i try to access these methods in a similar manner, i get the error "No visible #interface for 'TheFeedStore' declares the selector 'hasItemBeenRead:"
1) I have imported TheFeedStore.h file in the classes from i am
accessing these methods of TheFeedStore class.
2) I have checked like 10 times and there is no typo.
3) The methods i am accessing are also declared in the header file of
TheFeedStore.h
UPDATE: Just to check, i have declared another test method in TheFeedStore.h, same result, one class can access the newly created method while rest of the three classes cannot.
UPDATE: I have tried creating more methods in the TheFeedStore.h just for troubleshooting this issue. The new methods are also not accessible from the other classes. But if the return type of these new methods is (RSSChannel*) which is another model class in my project, than they become accessible. If their return type is other than some class like (void) and (BOOL) then they are not accessible. Here is my TheFeedStore.h https://gist.github.com/jessicamoore112/5558473
You have said that you are using #class instead of #import in your header files, the methods that you are trying to access are declared in the header files and there are no typos of any kind.
In such cases, usually no body points this issue but i am going to do it anyway because i have faced such issues many times. You have probably created many copies of your project to work on each functionality and also keeping a working project.
When you do this, sometimes Xcode is still using the older copies of few files. That means it is still using the older copy of the TheFeedStore.h when the methods you are trying to access were not declared by you.
How to solve this problem is very simple. Go to the file from which you are trying to access the methods and the files in which these methods are declared.
In the Utilities section on the right hand side, check the location and full path under "Identity and Type" area.
First check the names of the project, if it is different from the project name that you are working on, that means Xcode is still pulling the old copies of the files from the previous revision of your project. See the blue arrows where the project name is 13SampleMoreRequests in my case.
If this name is same as your project name, then my answer does not solve your problem. If its different, you should use the new copies of the file by browsing the new location using the sign that is pointed out by red arrow.
Once you browse and use the new files, your problem will be solved and you will be able to access the methods. If you still can't, copy these files, delete from the project and then add them again and you won't face this problem.
Hope this helps!
Cyclical imports, e.g. A.h imports B.h while also B.h imports A.h is the most common problem.
In C, cyclical imports won't work and one of the imports will be silently ignored. Make sure you are not having a cyclical import. If you do, solve it (e.g. using forward declarations).
Import problems can be also easily inspected if you generate the preprocessed output (you can find it in one of the Xcode menus).
That might sound silly, but I have similar cases once in a while and sometimes just simple quitting and starting xcode helps, it tends to stuck sometimes.
Also, sometimes cleaning the project helps.
'Cause I have very similar to yours singleton code and it works fine.
Guys I had encountered the exact same issues. After some searching on SO and the search engine I was able to solve it.
In my Case I have four files:
RadioStation.h
RadioStation.m
ViewController.h
ViewController.m
My mistake was to place all my methods in RadioStation.m and only put my variables on radioStation.h
So when I import radioSation.h on my ViewController.m and try to define methods for button-click on my app that's where the problems started.
I got the error/warnings "ARC Semantic Issue: No visible #interface for Class declares the selector" every time I built or ran the app simulator.
My Solution was to go back to RadioStation.h file and just declare all my methods there.
Since they were already defined on RadioStation.m I was good to go.
So make sure you have properly declared your methods on the file that is going to be imported on your viewControllers.
Hope that helps.
In my case I had some very strange path entries in
Framework Search Paths
Library Search Path
(Targets -> YOUR_APP_NAME -> Build Settings in "Search Paths" section)
I removed them and the error messages are gone.

Referencing Classes from Different Targets in xCode for iPhone Unit Testing

I am trying to unit test my iPhone application. I have created a new target and called it "LogicTests". But now I need to use a class called "Spaceship" inside the test. How can I do that?
UPDATE 1:
I made the Spaceship.m available to the unit testing target and that particular error was gone. Now I have different problem. The Spaceship.m file reference to the Cocos2d library. How can I add a reference to the Cocos2d library in the unit testing target. I tried right clicking the Link binary with libraries option and then adding the cocos2d framework but it gave me 153 errors or something.
To include it in that target, click on Spaceship.m, get the file's Info (Command-I), and make sure "LogicTests" is checked under the Target tab.
Beyond that, make sure you add
#import "Spaceship.h"
To the top of the particular test class. Good luck!
In Xcode 4 you press: Alt-Command-1 and then check that "LogicTests" is checked under the Target Membership tab.

Core-Plot: Unknown class CPLayerHostingView in Interface Builder file

Using core-plot does not seem to be an easy integration task. Header path are already setup. In Interface-Builder I create an CPLayerHostingView which belongs to a View Controller which is instantiated by Interface Builder.
When the nib file is loaded I get the message:
Unknown class CPLayerHostingView in Interface Builder file
I found, that there are two different versions of that object. One for Mac-Only called "CPLayerHostingView", one for iPhone only called "CPGraphHostingView".
If following the poplular example at http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application you would use the following lines, if building an iPhone-App:
CPGraphHostingView *graphView = (CPGraphHostingView*)self.view;
graphView.hostedGraph = graph;
http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application
Here is the answer ..
U can see mars' answer there
"i got it to work....ok, i added the -all_load -ObjC flag in the Target>Settings....I think this is where everyone gets confused...There are 2 places where to put the other link and header search paths, in Project Settings and in Target Settings.."
So solution is
Add -all_load -ObjC in Project settings and target settings
I had to rename CPLayerHostingView to CPGraphHostingView to get this to work after upgrading to the latest version of core plot (along with iOS 4 and the upgrade of XCode).
I think you're saying that you get this error when you load the NIB file in your app's code. In that case, the error suggests that you haven't built the Core Plot classes into your application (iPhone) or linked against the CorePlot framework and copied into the app bundle's Frameworks/ directory (OS X).
CPGraphHostingView
thank u it worked for me aswell;
3 imp things
1>perform settings for both project target aswell as application target.(make sure configuration is all configuration)
2>give correct header search path for framework library
3>learn over it::::::-)
For whatever it is worth.
Followed tutorial: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application and ended up having that same error. I looked into the CorePlot framework folder and did not find that CPLayerHostingView there, but found CPGraphHostingView inside iPhoneOnly folder.
Changed CPLayerHostingView to CPGraphHostingView in IB and error disappeared.
So, check what is in yours and use it. May work.