iPhone - NSError reference : constants and code - iphone

I'm searching some precise doc where I can associate an error number to its constant. Let's say, for example, I'm searching the constant of NSError.code = 102. How may I do to find it ? Searching the Web does not help. Searching the headers file is a headache.
How would you do this ?

you can find some of refrences here for NSError
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/Reference/Reference.html
you can found some of error detail here
http://www.lifeasbob.com/Code/ErrorCodes.aspx

The code should belong to the domain of NSError, check the documentation for the associated error domain and you should find the correct code. The domain is also a good hint of which headers to search if documentation is unavailable. Apple does list the Foundation Constants.

It's WebKitErrorDomain - WebKitErrorFrameLoadInterruptedByPolicyChange
Frame load interrupted error while loading a word document in UIWebView
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Miscellaneous/WebKit_Constants/#//apple_ref/doc/constant_group/WebKit_Policy_Errors

Related

CKAsset in server record contains no fileURL, cannot even check for nil

I am testing a sync conflict when I save a record that contains a CKAsset (simply a JPG image) using CKModifyRecordsOperation with a save policy of .IfServerRecordUnchanged. I am getting the error CKErrorCode.ServerRecordChanged. This CKError returns me useful information for conflict resolution, including the CKRecord I tried to save, and the current server version of the record. The first is in error.userInfo[CKRecordChangedErrorClientRecordKey] the second is in error.userInfo[CKRecordChangedErrorServerRecordKey].
My problem is I am trying to access the server record's CKAsset with this code:
if let photoAsset = rec["myPhoto"] as? CKAsset {
print("PhotoAsset.fileURL: \(photoAsset.fileURL)") // BAD_ACCESS ERROR HERE
self.myPartner.photo = NSData(contentsOfURL: photoAsset.fileURL)
}
I don't get how this is possible. But after further investigating, I print out the client and server CKRecords and the server one is missing the 'path' property.
client CKAsset...myPhoto (modified) -> CKAsset: 0x7b960d90; path=~/tmp/BF185B2C-7A39-4730-9530-9797E843243Aphoto, size=373959, uploadRank=0, uploadReceipt=A92Eg1qoyPG7yrg3, UUID=3C2D5DC8-4FF5-4A81-853B-395FC1C59862, referenceSignature=<012fd149 200fc600 617e3907 88763e3e 5002abbf 5b>, flags=uploaded, wrappedEncryptionKey=, signature=<0134a297 38d52f5f 9275bfba fce5b1a8 3d6b9692 d3>
server CKAsset...myPhoto = CKAsset: 0x7be700d0; referenceSignature=<015337bd 84409893 7c014f46 36248d27 ce911dc3 7a>, size=373959, uploadRank=0, UUID=DF5D2EB4-033C-49A2-AF52-6055B5A44106, wrappedEncryptionKey=<767e7cfd d1e62110 32119ee9 f6f026b3 5bcf0cc3 8053a4de>, signature=<0134a297 38d52f5f 9275bfba fce5b1a8 3d6b9692 d3>
Notice how path=~/tmp/C706423B-A3E8-4051-A9B3-483C718BFBF5photo is missing from the server one? Can anyone explain this? To fix it I try to avoid touching the CKAsset from the server record. I would like to at least be able to check for nil. I wanted to put this out there in case it helps anyone else.
Due to the crash on accessing fileURL, this is most likely a framework bug. Probably an oversight on account of the CKRecord being buried in a dictionary. I just follow it up with a regular fetch(withRecordID:).
I'm experiencing this issue as well on iOS 11.2.1 when accessing CKAsset from serverRecord property in CKRecord. It's a little bit frustrating. A workaround is fetching the object once again via func fetch(withRecordID... and then access fileURL.
This seems like the correct behavior, not a bug.
CloudKit informed you that your write operation failed because you weren't working from the latest CKRecord and gave you a non-hydrated version of the server's current CKRecord so you could determine which fields were different from your starting point. The rest is up to you.
If CloudKit returned the fully hydrated server record in the error response for a write operation, it would potentially waste enormous amounts of bandwidth/resources.
That is why CKAssets exist: to separate the size-constrained key-value fields associated with a CKRecord from the unlimited-size binary assets that can be attached to them.

(os/kern) invalid capability (20) invalid name(15) - I cant seem to get rid of these errors

First let me say I have researched this topic and looked through the following link and it did not help
Link 1
I tired un-checking elements in the Attributes Inspector (as described in link1) .
I also tried adding the code to the .plist file as described in LINK 2 and it did not help.
Where I seem to be getting the error is when i execute the following sequence of events using a button to start it:
user presses a button
alert pops up to ask the user if they wish to proceed
if yes a button now becomes un-hidden to allow the user to send data to my domain
once the new button is pressed I use a fetch to get a bunch of core data and then send it to my domain using an NSString(data: data!, encoding: NSUTF8StringEncoding)! call
right after all the data is sent to my domain I get the following error every time:
_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)
It does successfully send the data but the error stays... PLEASE HELP
I was getting this error executing not long run operations but some operations that take long on handler blocks of UIAlertActions. I solved by putting operations in a background thread with:
NSOperationQueue().addOperationWithBlock {
// Operations Here.
}
Accessing the core data can take longer then you think and accessing it from button handler can make that error appear because some handlers have limited amount of time to respond.
For me this error occurred when I tried to set the button title to an optional string:
self.titleButton.setTitle(self.playlistItem?.title, for: UIControlState())
The error messages do not occur when changed to this:
self.titleButton.setTitle(self.playlistItem!.title, for: UIControlState())
Feel free to post relevant code in your question.
Hope this helps...

Is there a list of MPMoviePlayer error codes

if a movie finishes with an error, then I might get an error like:
Error Domain=MediaPlayerErrorDomain Code=-12847 "This movie format is
not supported."
The same description is used for different error codes - but I can't find the code definitions anywhere.
Are they available?
Here you go. https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVFoundation_ErrorConstants/Reference/reference.html
God help you if your code (like mine) was -11800 (AVErrorUnknown).

Sudzc with iOS 5 and ARC

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

AVAudioPlayer initialization: error code -50

I recently ran into a problem that I couldn't find discussed anywhere on the internet - I was initializing an AVAudioPlayer to play an audio file, and getting the following error:
Error Domain=NSOSStatusErrorDomain Code=-50 "Operation could not be completed. (OSStatus error -50.)
As it turns out, I had made a mistake creating my NSURL to send to the audio player init method, resulting in the NSURL object being null. Stupid mistake, pretty easy to find when debugging, but I thought I'd list it here just in case someone else does the same thing.
“ OSStatus error -50” means paramErr, an old-style Mac error code indicating a bad parameter.
Regarding the comment from Brynjar:
The Apple NSURL Class Reference describing URLWithString states
To create NSURL objects for file system paths, use
fileURLWithPath:isDirectory: instead.
I have found that using URLWithString for file system paths generates the error reported by pix0r and therefore could be another explanation for error code = -50
Make sure your NSURL is valid, or you will get error code -50 "Operation could not be completed".
I'm adding my version of the issue and solution because I encountered the error with a print statement. I think it was related to string interpolation and or trying to forcibly print nsattributedstrings. I attempted to do the following.
print("THE ARRAY COUNT IS : \(unwrappedResults.count)\n\n\n
THE FULL ARRAY IS THE FIRST WHOLE RESULT IS: \(unwrappedResults)\n\n\n \ (unwrappedResults[0])\n
THE ATTRIBUTED FULL TEXT IS: \(unwrappedResults[0].attributedFullText)\n\n\n
THE ATTRIBUTED PRIMARY TEXT IS: \(unwrappedResults[0].attributedPrimaryText)\n\n\n
THE ATTRIBUTED SECONDARY TEXT IS: \(unwrappedResults[0].attributedSecondaryText)\n\n\n")
something about this was incorrect and no print would occur. I would receive the error following errors in my console.
boringssl_metrics_log_metric_block_invoke(131) Failed to log metrics
&
boringssl_metrics_log_metric_block_invoke(133) Error Domain=NSOSStatusErrorDomain Code=-50 "Unsupported xpc type"
UserInfo={NSDescription=Unsupported xpc type}
I fixed this issue by changing the way I unwrapped/the variables values. Fundamentally I think I was trying to print something using string interpolation that could not be printed and that is what caused this error.