CloudKit Zone CKSubscriptionOptions - cloudkit

I am getting an error setting up a zone subscription for a custom zone.
let mainZoneID=CKRecordZoneID(zoneName: "MainZone", ownerName: CKOwnerDefaultName)
let subscription=CKSubscription(zoneID: mainZoneID, options: CKSubscriptionOptions.FiresOnRecordCreation)
The error message I get says "*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'CKSubscriptionTypeRecordZone subscriptions are incompatible with subscription options 1'"
I found a link that shows the use of CKSubscriptionOptions.allZeros but that is not an option in the iOS 9 SDK at least.
The Apple docs reference setting it to 0 but when I do that, it will not compile.
From the docs: "The configuration options for the subscription. You must specify 0 for this parameter. Zone subscriptions currently do not support any options."
See code snippet below:
let subscription=CKSubscription(zoneID: mainZoneID, options: 0)
The compiler error says I can not use an Int for an option. Does anyone know how to setup a zone subscription on a custom zone? Is this a bug?

Indeed the CKSubscriptionOptions enum does not have an option for 0. You can force a value of 0 by using CKSubscriptionOptions(rawValue:0)

Related

Realm Migration Swift

I added a new Class ,newClass, to my Realm file through Realm Studio to allow users to manage an array of items. I also created swift file to manage the new class in XCode.
Since running the app immediately after doing the above, all my data from the firstClass, has disappeared (not a problem the user adds all data in this class on startup, I can repopulate whilst testing the app.)
My app now crashes whenever it reaches any code let realm = try! Realm(). I have commented out or removed references to these to see if it is a localised problem, but it still continuous to crash with the following similar errors depending on the VC it crashes on when during let realm = try! Realm().
schema version 1
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=1 "Provided schema version 0 is less than last set version 1." UserInfo={NSLocalizedDescription=Provided schema version 0 is less than last set version 1., Error Code=1}: file /Users/UserName/Desktop/AppName/AppName/Custom VC's/AddDataToRealmViewController.swift, line 168
2020-06-27 13:23:10.481817+0100 AppName[4498:173994] Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=1 "Provided schema version 0 is less than last set version 1." UserInfo={NSLocalizedDescription=Provided schema version 0 is less than last set version 1., Error Code=1}: file /Users/UserName/Desktop/AppName/AppName/Custom VC's/AddDataToRealmViewController.swift, line 168
After doing a little bit of reading around, it suggest I need to migrate my realm file to the new schema? Before I attempt this, would this be the correct course of action to take?

Crash when using deleteRealmIfMigrationNeeded with Realm in Swift

I'm doing the following inside of didFinishLaunchingWithOptions:
let config = Realm.Configuration(
schemaVersion: 0,
deleteRealmIfMigrationNeeded: true
)
Realm.Configuration.defaultConfiguration = config
let realm = try! Realm()
Basically, while developing, I don't want to worry about migrations and just want to clear the database whenever the schema changes. My understanding is that's exactly what deleteRealmIfMigrationNeeded is for.
The problem is that sometimes it crashes while trying to initialize Realm with the following error:
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=5 "Directory at path '/Users/rock/Library/Developer/CoreSimulator/Devices/D626848E-14D5-47AC-8FFB-9B67D024DEF1/data/Containers/Data/Application/6F71103C-9E10-4131-BED4-D96445FABA52/Documents/default.realm' does not exist."
The default.realm file is getting removed, presumably because of deleteRealmIfMigrationNeeded, but then isn't getting recreated (as I'd expect) when initializing Realm with that last line.
Interestingly, if I manually delete default.realm.lock and then restart the app, it'll work.
Am I doing this wrong? Could this be a bug? (I'm using Realm Swift 2.4.1)
I just came across the same problem and the solution in my case was to turn off the Realm Browser if you have it open.
Cheers!
I discovered that turning off encryption when setting up the Realm will allow you to have the Realm Browser open at the same time.

How can I get unacked messages in rabbitmq in swift language?

In java, I'm getting unacked messages with channel.basicRecover(true), Is there anything like this in swift?
I'm also getting this error when I use channel.recover() in swift version.
allocator = <RMQMultipleChannelAllocator: 0x15c7f28a0>>
error: Error Domain=com.rabbitmq.rabbitmq-objc-client Code=8 "Expected RMQChannelOpenOk, got (null)."
UserInfo={NSLocalizedDescription=Expected RMQChannelOpenOk, got (null).}
channel.recover() is really a private API for doing automatic connection recovery. We've recently documented this here: https://github.com/rabbitmq/rabbitmq-objc-client/blob/master/RMQClient/RMQChannel.h#L98
We currently don't have basicRecover support, like Java. If you have a use for it, please file an issue: https://github.com/rabbitmq/rabbitmq-objc-client/issues

(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...

NSNull cc_componentsForMonthDayAndYear in Kal calender error ios

I am developing iPhone application that persists data to a SQLite3 database.
Also I am using Kal calender. Here I able to get Calender successfully But when I inserted Date from SQLite3 database. It get crashed by giving error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull cc_componentsForMonthDayAndYear]: unrecognized selector sent to instance 0x3f8a85e0'
I am not getting what's wrong going here..
I have go through several search pages..
I tried to solve this by two way feting double as NSDate like
[NSDate dateWithTimeIntervalSince1970:sqlite3_column_double(selectstmt, 4)]
and this way to Fetching NSDate using NSDateFormatter [dateformate dateFromString dateString]
please help me regarding this ASAP...
I think some values are not retrieved correctly,
Check whether the object that is used to call "componentsForMonthDayAndYear" contains value.
provide a null check before calling "componentsForMonthDayAndYear" method which will help you to avoid this type of exception
if (object != NSNull.null) {
[object cc_componentsForMonthDayAndYear];
}