Sunday, 20 May 2018

Reading data from Local Json file using Alamofire in swift3


//Reading data from Local Json file instead of Service urls using Alamofire in swift3


func getwordmeaningdata()
  {
   
    if let path = Bundle.main.path(forResource: "localfile", ofType: "json") {
       let url=URL(fileURLWithPath: path)
        Alamofire.request(url).responseJSON { response in
            
            if let JSON = response.result.value {
                print("JSON: \(JSON)") 
            }
        }
}


//This is the data of local json file not getting from URL
localfile.json


{
  "person":[
    {
      "name": "Bob"
     
    },
    {
      "name": "Vinny"
      }

]
}

Tuesday, 15 May 2018

Read data from textfile in swift 3


let path = Bundle.main.path(forResource: "textfile", ofType: "txt")
 print(path!)
                
let url = URL(fileURLWithPath: path!)
 print(url)
                
 let contentString:String = try! String(contentsOf: url, encoding: String.Encoding(rawValue: String.Encoding.utf8.rawValue))

//if convert to Data

 let data = contentString.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue), allowLossyConversion: false)!
                        

print("string\(contentString)")


Wednesday, 21 March 2018

Localization in swift 3

step 1 : Add the Language





-->file will added like above image

Step - 2 : Add the String file

create String file and rename it as "Localizable.strings"





Step 3 : Configure String file for Localization



Step - 4 : Add the key values to get the value



note: we may check files are created in currect format or not by using cmds
  1. cd into your project root
  2. cd en.lproj - you can replace this with any localisation you are working with.
  3. plutil -lint Localizable.strings

step - 5:

we can switch the language on buttons like


  @IBAction func english(_ sender: Any) {
        
        let path = Bundle.main.path(forResource: "en", ofType: "lproj")
        let bundel = Bundle.init(path:path!)! as Bundle
   countryName.text=bundel.localizedString(forKey: "usernametitle", value: nil, table: nil)
    }
    //pt-PT.lproj

    @IBAction func protual(_ sender: Any) {
        let path = Bundle.main.path(forResource: "pt-PT", ofType: "lproj")
        let bundel = Bundle.init(path:path!)! as Bundle
        countryName.text=bundel.localizedString(forKey: "usernametitle", value: nil, table: nil)
    }



change forResource string based on language



Saturday, 24 February 2018

Publish app in Appstore and send invitation through testflight and generate App Icons


Every app must provide an icon to be displayed on a device’s Homescreen and in the App Store. An app should specify several different icons of different dimensions to suit different screen sizes and different situations.
You can save valuable time by using Makeappicon.com to generate app icons



for publish follow this link 
https://www.youtube.com/watch?v=tnbOcpwJGa8

Saturday, 10 February 2018

hiding tabbar at bottom with space in swift 3


self.tabBarController?.tabBar.isHidden = true
self.extendedLayoutIncludesOpaqueBars = true

Friday, 27 October 2017

how switch to specific tab programmatically if click on button in UITabBarItem

I have a button in Viewcontroller in UITabBarItem, I want to switch to a specific tab

Just use this:
tabBarController?.selectedIndex = 1

Tuesday, 24 October 2017

Cmd + click, jumping to definition in Xcode 9 issue?

If cmd+click is not working in Xcode 9, here is the solution

Xcode9-Preferences->Navigation->Command-click on Code:->Jump To Definition



if still not found

  1. File > Workspace Settings
  2. Click over the little grey arrow above Advanced... Button (Derived Data)
  3. Select my project folder and delete it.
  4. close the xcode and reopen clean and build 


Remove bottom line in navigation bar

navigationController ?. navigationBar . setBackgroundImage ( UIImage (), for: . any , barMetrics: . default )          navigat...