I am new to Swift, iOS development.
HTTP Request :
request.httpBody = postString.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data, error == nil else { // check for fundamental networking error
print("error=\(error)")
return
}
if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 { // check for http errors
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(response)")
}
let responseString = String(data: data, encoding: .utf8)
print("responseString = \(responseString)")
}
task.resume()
Response String looks like this
BEGIN:VCALENDAR
PRODID:-//MobileUGStdTT//iCal4j 1.0//EN //DateGenerated 06 May 2017 12:05
:07
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20170506T040507Z
DTSTART:20170109T090000
DTEND:20170109T120000
SUMMARY:SG4207 (L)
DESCRIPTION:SG4207-MOBILE WIRELESS SOLUTION DESIGN (LECTURE)
LOCATION:ISS-03-03
UID:20170506T040507Z-MobUGStdTT@fe80:0:0:0:250:56ff:fea6:c7e%3
TZID:Asia/Singapore
BEGIN:VALARM
TRIGGER:-PT15M
REPEAT:4
DURATION:PT5M
ACTION:DISPLAY
DESCRIPTION:SG4207-MOBILE WIRELESS SOLUTION DESIGN (LECTURE) @ ISS-03-03\
, starts 0900
END:VALARM
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20170506T040507Z
DTSTART:20170116T090000
DTEND:20170116T120000
I need to convert this response to NSDataDictionary
/ENUM
, Since its not a regular JSON
I am finding it hard to convert it to.
These are the Keys - DTSTART,SUMMARY,DESCRIPTION I am in need of.
Thanks for your help.