Convert Objective-C to Swift

objective-c to swift converter github
objective-c to swift tutorial
convert swift 2 to swift 4 online
convert swift 3 to swift 4 online
convert objective-c to c# online
convert swift code to objective-c code online
convert objective-c block to swift
objective to swift 3

Can anybody help to convert this objective-c code into swift:

NSMutableDictionary *data = [NSMutableDictionary dictionaryWithCapacity:0];
for (NSString *key in trDict) {
    [data setValue:[NSString stringWithFormat:@"%@ %d", key, i] forKey:key];
}

Some Suggested? Thanks.


You can use this loop to get the data and keys:

var data = Dictionary<String, String>()
for (key, obj) in trDict {
    data[key] =  "\(key), \(obj)"
}

You cannot get index from dictionary because dictionary is unordered collection

Swiftify, A step-by-step approach. Pick a pair of .h and .m files to be converted into Swift (​i.e. MyViewController.h and MyViewController.m). If  Do not seek to convert Objective C project to Swift completely. It is likely that in addition to the classes that are inherited from Objective-C, there will be a number of constructs in the code that are more successfully expressed in its original form.


This is information that is available in the "Introduction to Swift" in the book released (for free) by Apple.

var dataDictionary: [String, String] = [:]

for (key, value) in trDict {
    dataDictionary[key] = "\(key) \(value)"
}

Migrating Your Objective-C Project to Swift - Swiftify, The first step is easy and as simple as creating a swift file in the Objective-C app. To create a swift file, go to New File menu in Xcode and then select iOS source  iSwift is the best tool for Mac to convert your old Objective-C code and projects to Swift. With just a single click. Don't believe me? Why not try our little demo 100% online and judge for yourself? :-) Just type in some Objective-C, click Convert and that's it. At the right part of the screen, the converted - Swift - code will appear. Ready to use.


You can also use enumerateKeysAndObjectsUsingBlock method to enumerate NSMutableDictionary.

var data = NSMutableDictionary(capacity: 2) as NSMutableDictionary!
data.setValue("Value1", forKey: "Key1")
data.setValue("Value2", forKey: "Key2")

data.enumerateKeysAndObjectsUsingBlock { (key, obj, stop) -> Void in
    var string = "\(key) \(obj)"
    data.setValue(string as String, forKey: string)
}

How to Convert an Objective-C IOS App to Swift, In all instances, Objective-C code is shown on the left and the equivalent Swift code on the right. Where necessary I have added small clarification  The main reason behind this process that convert apps from Objective-C to Swift is that to revise an already existing application and to make improvements in its logic, architecture, and overall performance. This is done by replacing the previously existing pieces of objective c with the newer and better components of swift.


Objective-C to Swift conversion cheat sheet – Hacking with Swift, iSwift is the best tool for Mac to convert your old Objective-C code and projects to Swift. With just a single click. Don't believe me? Why not try our little demo  The process of Migrating Objective-C code to Swift The most effectual approach to convert a full Objective-C app to Swift is, to begin with, one class at a time, especially a class without any subclass since you can’t subclass Swift classes in Obj-C. Replace the.m and.h files related to the class with a single.swift file.


Convert Objective-C to Swift online for free, Objective-C code can not be automatically converted to Swift. But you can migrate Objective C app to Swift manually. macOS IDE Xcode helps in the smooth  Convert the pair of Objective-C files to Swift. The Finder extension included in Swiftify for Xcode is the easiest way to do that. Alternatively, copy contents of both.h and.m files to a.swift file


How to automatically convert Objective-C to Swift, Your approach of converting Objective-C to Swift is wrong! Apple also took time to adopt Swift completely in their frameworks and the news is in  Can anybody help to convert this objective-c code into swift: NSMutableDictionary *data = [NSMutableDictionary dictionaryWithCapacity:0]; for (NSString *key in trDict) { [data setValue:[NSString