I am trying to upload a picture to TwitPic using GSTwitPicEngine.
I have included all the requirements but it seems that some functions used in OARequestHeader class are not recognized. Here is an example:
[chunks addObject:[NSString stringWithFormat:#"realm=\"%#\"", [realm encodedURLParameterString]]];
The "encodedURLParameterString" function is not recognized. realm variable is a NSString.
Do you have any idea what I have done wrong?
Thanks,
Andrei
YEP!
You are missing one file or missed to include it (it's part of OAuthConsumer).
Simply download
NSString+URLEncoding.h
and
NSString+URLEncoding.m
from http://oauth.googlecode.com/svn/code/obj-c1/OAuthConsumer/NSString+URLEncoding.h
and http://oauth.googlecode.com/svn/code/obj-c1/OAuthConsumer/NSString+URLEncoding.m
and add the #import line into the file, where the error appeared:
#import "NSString+URLEncoding.h"
This will add "encodedURLParameterString" to NSStrings selectors.
Related
I'm new to the coding industry and am seriously struggling with Swift. I have a situation where I want to go from one page to another, but I keep getting an error of "use of undeclared type AVCamViewController. This is my code:
#IBAction func goToApp(sender : AnyObject) {
let AVCam = self.storyboard.instantiateViewControllerWithIdentifier("AVCam") as? AVCamViewController.h
self.navigationController.pushViewController(AVCam, animated: true)
}
And if I try to import the AVCamViewController or AVCamViewController.h or AVCamViewController.m, I get an error of 'no such module'.
I have have all the files of the AVCam application in my app so I am not sure what to do. Any advice please?
You need to remove .h from line when you instantiate vc:
let AVCam = self.storyboard.instantiateViewControllerWithIdentifier("AVCam") as? AVCamViewController
AVCamViewController.h is file name but you need class name which is AVCamViewController
Do you have a bridging header set up? If AVCamViewController is a system class, you have to #import the right framework, i.e. #import AVFoundation. Otherwise, you have to create a header specifically for use as a bridge from Objective C to Swift. In said header, you include your own headers that you want Swift to see. You will have to set the build settings to point to the new header. If you added a new Swift class/file, Xcode should have asked if it could create one automatically. If you do have one, you can put your header imports/includes into that file.
I've been trying to get a webservices working using Sudzc. Whenever I convert my WSDL to obj-c without automatic reference counting it works just fine. The problem is, we are building all our applications in iOS 5 now and all our code uses ARC. Sudzc now also allows you to create a bundle with ARC enabled but when I run this code it always returns null.
I tried debugging the Sudzc code and it does receive a correct xml response back from the service. Somewhere something is lost in translation. I tried converting the working Sudzc code without ARC into code with ARC enabled but as soon as I've fixed all errors it returns null again.
Did anyone encounter this and know what is going wrong? Would save me loads of time not having to debug the whole Sudzc code by myself.
In my case (SUDZC with ARC for IOS), I have replaced the folowing code in SoapRequest.m file;
CXMLNode* element = [[Soap getNode: [doc rootElement] withName:#"Body"] childAtIndex:0];
with
CXMLNode* element = [[Soap getNode: [doc rootElement] withName:#"soap:Body"] childAtIndex:0];
Somehow the respective function is searching for the root element with name "Body". After inspecting the soap envelope it is easy to see the root element's name is "soap:Body".
My webService was create in Java with Axis Eclipse.
FOR ARC I use : "soapenv:Body"
And in the file SoapObject.m I add
#import "Soap.h"
#import "SoapObject.h"
In my case "env:Body" worked. Check your return xml (by printing) and replace appropriately
In my case it was an .Net web service (WCF) and I had to use s:Body:
Found out by printing the CXML document:
CXMLNode* test = [doc rootElement];
NSLog(#"%#",test);
Here I got this:
<CXMLElement 0x68c1a50 [0x68c1b10] s:Envelope <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><**s:Body**><GetUserIDResponse xmlns="http://tempuri.org/"><GetUserIDResult>8</GetUserIDResult></GetUserIDResponse></s:Body></s:Envelope>>
Thanks to previous posts I was able to find it out and posted the complete answer again on my blog: http://www.dailycode.info/Blog/post/2012/08/07/SUDZC-webservices-always-return-0-(WCF-web-service-and-IOS-client).aspx
I have the following code:
NSString *subtitle = [[[node elementsForName:#"subtitle"] objectAtIndex:0] stringValue];
NSString *duration = [[[node elementsForName:#"itunes:duration"] objectAtIndex:0] stringValue];
The first line works perfectly. The second line though won't work. I assume it has something to do with namespaces, but I'm pretty new to all of this so I would appreciate any guidance. Thank you!
It turns out that I can use the elementsForLocalName:URI: to read the element correctly. Now the problem is that since I am using the TouchXML library, it doesn't seem like that method has been mapped over to the CXMLElement structure (see here).
So the question now is: how can I convert a CXMLElement to an NSXMLElement so that I can use that method?
"itunes" is the namespace identifier. It doesn't actually have any significance on its own, it just links a URI with the element in question. It looks like you're using the iTunes RSS extensions, which live under the namespace http://www.itunes.com/dtds/podcast-1.0.dtd.
So, for namespaced elements, I think (I'm not familiar with Objective-C or NSXML :P) you want to use elementsForLocalName instead:
[node elementsForLocalName: #"duration" URI: #"http://www.itunes.com/dtds/podcast-1.0.dtd"]
For the answer to the second question, see comments below.
I'm having trouble compiling the current release.
I was able to download a copy of the source distribution today using:
hg clone https://core-plot.googlecode.com/hg/ core-plot
I opened the "core-plot/framework".
I then double clicked on CorePlot-CocoaTouch.xcodeproj to launch Xcode.
When I build the project I get the following error:
-(void)bind:(NSString *)binding toObject:(id)observable withKeyPath:(NSString *)keyPath options:(NSDictionary *)options
{
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
[NSException raise:CPException format:BindingsNotSupportedString];
Format not a string literal and no formal arguments
#else
[super bind:binding toObject:observable withKeyPath:keyPath options:options];
#endif
}
I am running on a new MacBook with OS 10.6, and IPhone Simulator 4.0.
Any help will be greatly appreciated.
Charles
A more appropriate place to ask this question would be the Core Plot mailing list, because I'm one of the few developers for the project that regularly visits here.
That said, the issue here is that we're using a string constant for a format string, which Xcode now seems to be warning about (rightly so, as this can lead to problems). To work around this for now, you can replace the line in CPLayer.m
static NSString * const BindingsNotSupportedString = #"Bindings are not supported on the iPhone in Core Plot";
with
#define BindingsNotSupportedString #"Bindings are not supported on the iPhone in Core Plot"
Search in your project for BindingsNotSupportedString, seems like it's not in the current file and therefore needs to be included. Or just try to change this to an acceptable format.
The following code produces this build warning:
NSData may not respond to
'dataWithBase64EncodedString:'
The code:
NSString * message = #"string string string";
NSData *data= [NSData dataWithBase64EncodedString:(NSString *)message];
How do I fix this to remove this warning?
Removing the warning is the least of your worries - NSData doesn't respond to that method and this code will crash if you run it!
See the docs here for the default available methods on NSData.
However, you're probably looking for this page which has an implementation of dataWithBase64EncodedString in a category (see the very last post on the thread!)
NSData does not have dataWithBase64EncodedString: method. If you use some custom NSData category with this method you should import header where it is defined.
Edit: So if you're using code from this link then you can just create your own .h and .m files and copy that code into them:
// MBBase64.h
#interface NSData (MBBase64)
+ (id)dataWithBase64EncodedString:(NSString *)string; // Padding '=' characters are optional. Whitespace is ignored.
- (NSString *)base64Encoding;
#end
//MBBase64.m
static const char encodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
#implementation NSData (MBBase64)
...
#end
And then import MBBase64.h header wherever you want to use +dataWithBase64EncodedString: method.
Just to clarify the previous answers:
In the NSFoundation API, NSData does not have a dataWithBase64EncodedString: method. If your copying code in which it does, then that code has extended NSData by adding to it a category that contains the method.
You can add arbitrary methods to any class using a category. If someone has used a category in their example code, you cannot use that code unless you also get the header and implementation files that define the category. If the original author did not make those available then you are out of luck.
Base64 encoding isn't one of the API provided encodings for strings so you'll probably have to implement that yourself or find some code by someone who has.