I am writing a subclass for NSOperation with swift. However, I met a strange problem.
class Downloader : NSOperation, NSURLSessionDelegate, NSURLSessionDownloadDelegate{}
When I add "NSURLSessionDownloadDelegate", it will show an error:"Type 'Downloader'does not conform to protocol 'NSURLSessionDownloadDelegate' "
When I delete it, every thing is Ok.
Do you know WHY?
Thanks, advance!
According to apple docs https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSURLSessionDownloadDelegate_protocol/index.html
implementing
URLSession:downloadTask:didFinishDownloadingToURL:
is necessary,
Please make sure that you have implemented it.
Related
I just have updated my Unity to 5.3.1 and it seems like EditorApplication class is already deprecated. The Unity suggests me to use instead the EditorSceneManager.OpenScene but looks like it's not returning of type bool anymore. Therefore causing my game to stop compiling.
Any help about this?
Thanks!
Usually due to deprecated code unity itself offers some changes in your code you can make a backup and try that if unity informs you of it ,but if you want to know if it has been loaded or not you can use its return value which is a struct of type Scene.
SceneManagement.Scene newScene = EditorSceneManager.OpenScene("myScene");
if(newScene.isLoaded) {
//do something
}
There is another method also named IsVaild You Can try that too.
further doc :
http://docs.unity3d.com/ScriptReference/SceneManagement.Scene.html
It's hard to help you without any information on what you actually want to do... This link may help though, it's about upgrading to Unity 5.3.
After successfully implementing the MFMailComposeViewController in my app, run it in the simulator and my iPhone, where it still works fine, it just crashed.
I get 5 MFMailComposeViewController.h issues: Cannot find protocol declaration, Expected identifier or '(', etc,...
My Controller header includes:
MessageUI/MessageUI.h
MessageUI/MFMailComposeViewController.h
and conforms to protocol:
#interface DetallViewController : UIViewController < UIActionSheetDelegate,
MFMailComposeViewControllerDelegate>
I've tried to:
1) remove and add the framework
2) Restart the device and Xcode as suggested in many posts
3) Create a separate controller to handle MFMailComposeViewController
After 3 days with this issue I'm completely stuck on this. As you can imagine, any help would be appreciate.
I would think this is a kind of reference issue since it appears whether the framework is selected or not.
Thanks in advance
Just to anybody it may help, I finally found the issue:
A missing #end in an imported header.
Thanks to everybody for the efforts.
There are 2 "writeImageToSavedPhotosAlbum" methods in ALAssetsLibrary Class:
- (void)writeImageToSavedPhotosAlbum:(CGImageRef)imageRef
metadata:(NSDictionary *)metadata
completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock
(available on iOS 4.1+)
- (void)writeImageToSavedPhotosAlbum:(CGImageRef)imageRef
orientation:(ALAssetOrientation)orientation
completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock
(available on iOS 4.0+)
I am using the 1st one (need iOS 4.1) in my code and it will crash on iOS 4.0 device. I am trying to use respondsToSelector to check which method is supported, however looks like the selector only check the method name, not the parameters.
I read some suggestions and feel it might not good by purely check on OS version, so is there anything similar to respondstoselector that can help me solve this problem?
You misunderstand the Objective-C method naming system. The selector is the combination of all foo:bar:baz: combined.
So, in this case, there is no method called writeImageToSavedPhotosAlbum. The first one is, as a selector, corresponds to
#selector(writeImageToSavedPhotosAlbum:metadata:completionBlock:)
and the second one is
#selector(writeImageToSavedPhotosAlbum:orientation:completionBlock:)
In your code, check whether the first selector is available or not, as in
if([obj respondsToSelector:#selector(writeImageToSavedPhotosAlbum:metadata:completionBlock:)]){
....
}
This should distinguish whether the first one is available or not.
These methods have different names, so you can test them separately.
if ([assetsLibrary respondsToSelector:
#selector(writeImageToSavedPhotosAlbum:metadata:completionBlock:)]) {
// Now you can safely use this method.
}
If you wanted to test the other one you would use #selector(writeImageToSavedPhotosAlbum:orientation:completionBlock:).
You can then differentiate them with os version. How about it?
im compiling my app , which is working great and i wanted to ask you 2 questions
1. im getting about 14 warnings like that
no '-addCategory' method found
which i know how to solve but even after i cleaned everything added the function to the header file and compile again it's still there i cant get rid of it.
2. im pretty new in coding and the code is not GREAT but it's ok how do i know apple will accept it ?
thank you very much !!
Declare that method in .h file
Implement that method in .m [implementor of .h] file .with the same signature.
Clean in once.
And try..
It should work..!
Can anyone please help me to solve the following error:
Error cannot find interface declaration for 'NSManagedObject', superclass of
Try
#import <CoreData/CoreData.h>
Are you missing an include statement?
Are you subclassing NSManagedObject? If so, go here in Apple's documentation and scroll to Xcode Generated Subclasses. They give you instructions to have Xcode generate class files from your data model.
A suggestion: Core Data is rather difficult, and you should be comfortable with iPhone development before you start working with it.
import CoreData to your xxx-Bridging-Header.h will make sense.