Tag: swift

Want to add event in google calendar

I want to insert event in google calendar without using any third parties. Please help me if any one know it. Thanks in advance.

Convert Base64 GZipped string Objective-c or Swift

I received a string from a web service like this: CAAAAB+LCAAAAAAABADtvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee++997o7nU4n99//P1xmZAFs9s5K2smeIYCqyB8/fnwfPyJOp/PqTf6u/X8A1v85+wgAAAA= The source string was “EchoText” that compressed with Gzip then converted to Base64. I have to decode Base64 string at first then Unzip that using Gzip. How can I do in Swift (or Objective-C)? Edit: I found a good library for using Gzip: nicklockwood/Gzip […]

Swift 2 Protocol Extensions and Conformance for Objective-C Types

I have a setup like this: @interface Model: NSManagedObject … @end And a Swift protocol like this: @objc protocol Syncable { var uploadURL: String { get } var uploadParams: [String: AnyObject]? { get } func updateSyncState() throws } extension Syncable where Self: NSManagedObject { func updateSyncState() throws { … /* default implementation */ … } […]

In Apple's Documentation for NSObject, what is the idea of the “receiver”?

I’m researching Object-Oriented Programming in Swift and I figured a great place to start would be NSObject, since all objects inherit from this base class. In Apple’s documentation for NSObject, there are areas that refer to a “receiver”. Does “receiver” mean an instance of NSObject?

What am I doing wrong in Swift for calling this Objective-C block/API call?

I’m using RedditKit to integrate Reddit into an app, and in Objective-C I called the API as follows (and it worked fine): [[RKClient sharedClient] signInWithUsername:@”username” password:@”password” completion:^(NSError *error) { RKPagination *pagination = [RKPagination paginationWithLimit:100]; [[RKClient sharedClient] linksInSubredditWithName:subredditSelected pagination:pagination completion:^(NSArray *collection, RKPagination *pagination, NSError *error) { // code that executes on completion }]; }]; Here’s how […]

How to determine if undocumented value for NS_ENUM with Swift 1.2

For instance, following NS_Enum is defined… typedef NS_ENUM(NSInteger, Type) { TypeNone = 0, TypeA = 1, } var x = 2 if let type: Type = Type(rawValue: x) { // Swift 1.2 executes this block. } else { // Previous swift executes this block. } How can I determine if x is defined on NS_ENUM […]

NSStoryboardSegue sample code (Yosemite Storyboard)

OS X Yosemite introduced NSStoryboardSegue “A storyboard segue specifies a transition or containment relationship between two scenes in a storyboard…” Update: • If I attempt to use a NSStoryboardSegue subclass in a Storyboard with Yosemite., it crashes with SIGABRT. • If I ignore segues, and manually present a view controller using a specified, custom animator […]

How to make a class conform to a protocol in Swift?

in Objective-C: @interface CustomDataSource : NSObject <UITableViewDataSource> @end in Swift: class CustomDataSource : UITableViewDataSource { } However, an error message will appear: Type ‘CellDatasDataSource’ does not conform to protocol ‘NSObjectProtocol’ Type ‘CellDatasDataSource’ does not conform to protocol ‘UITableViewDataSource’ What should be the correct way ?

how to set the selected check mark as ticked in tableview cell swift 3.0

I am using one UITableView to select the country with tick mark. But when I move to other screen and when I come back my check mark is invisible. It seems like the country what I am selecting is fine, But after I move to other screen an come back, The selected tick mark is […]

Cannot reference a local function error in Xcode 6 beta 6

I have just updated to Xcode 6 beta 6 from beta 4 and I am receiving an error that I don’t understand. I am getting the error ‘Cannot reference a local function from another local function’. var alert = UIAlertController(title: “Start Over”, message: “Are you sure you want to start over? This will erase your […]