after step by step reviewing of my code finally i figured out issues in my code. If you have more syntax mistakes in your code
the swift 2.x Xcode
compile stops showing the syntax mistakes & gives the error an internal error occurred . Source editor functionality is limited . Attempting to restore...
The corrected formatting of code is -
import UIKit
class SplitEvents: NSObject
{
var eventDisplayArray = NSMutableArray()
var eventHiddenArray = NSMutableArray()
var lastMemorisedDate:NSDate?
var tempEventStartDateEndDateArray = NSMutableArray()
func InitialiseFunction (displayArray:NSMutableArray, hiddenArray:NSMutableArray, result:NSArray, completionHandler:(NSMutableArray?,NSMutableArray?, NSError?)->Void) ->Void
{
eventDisplayArray = displayArray
eventHiddenArray = hiddenArray
SplitEvent(result.mutableCopy() as! NSMutableArray)
completionHandler(eventDisplayArray,eventHiddenArray, nil)
}
func SplitEvent(result:NSMutableArray)->Void
{
if(eventDisplayArray.count>0)
{
for event in result
{
for existingEvent in eventDisplayArray
{
if ((existingEvent as! Event).eventID == (event as! Event) .eventID)
{
result.removeObject(event)
break
}
}
}
}
for event in result
{
tempEventStartDateEndDateArray = []
for dict in (event as! Event).eventSatrtEndDateRange
{
tempEventStartDateEndDateArray.addObject(dict)
}
if (tempEventStartDateEndDateArray.count>1)
{
event.eventSatrtEndDateRange.removeAllObjects()
var tempStartEndDateArray:NSMutableArray = []
var i:Int = 0
for fisrtDict in tempEventStartDateEndDateArray
{
let df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if ((fisrtDict["start"] as! NSDate).isEqualToDate((fisrtDict["end"] as! NSDate)))
{
tempStartEndDateArray.addObject(fisrtDict)
var currentDate:NSDate = fisrtDict["start"] as! NSDate
var calendar:NSCalendar = NSCalendar.currentCalendar()
var dayComponent:NSDateComponents = NSDateComponents()
dayComponent.day = 1
currentDate = calendar.dateByAddingComponents(dayComponent, toDate:(fisrtDict["start"] as! NSDate), options:NSCalendarOptions(rawValue: 0))!
if (i+1 >= tempEventStartDateEndDateArray.count)
{
event.eventSatrtEndDateRange.removeAllObjects()
var temp:Event = CreateTemporaryObject(event as! Event)
if ((event as! Event).savedEventsEndDates.count > 0)
{
if ((event as! Event).savedEventsEndDates.containsObject(fisrtDict["end"] as! NSDate ) == false)
{
temp.attending = ""
}
else
{
temp.attending = (event as! Event).attending
}
}
else
{
temp.attending = (event as! Event).attending
}
temp.eventStartDate = ((tempStartEndDateArray[0]["start"]) as! NSDate)
temp.eventEndDate = (tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"] as! NSDate)
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray as [AnyObject])
GroupObjectArray(temp)
tempStartEndDateArray.removeAllObjects()
}
else
{
var secondDict: NSMutableDictionary = tempEventStartDateEndDateArray[i+1] as! NSMutableDictionary
if (currentDate.isEqualToDate(secondDict["start"] as! NSDate) == false)
{
event.eventSatrtEndDateRange.removeAllObjects()
var temp:Event = CreateTemporaryObject(event as! Event)
if ((event as! Event).savedEventsEndDates.count>0)
{
if ((event as! Event).savedEventsEndDates.containsObject(fisrtDict["end"] as! NSDate) == false)
{
temp.attending = ""
}
else
{
temp.attending = (event as! Event).attending
}
}
else
{
temp.attending = (event as! Event).attending
}
temp.eventStartDate = (tempStartEndDateArray[0]["start"] as! NSDate)
temp.eventEndDate = (tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"] as! NSDate)
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray as [AnyObject])
GroupObjectArray(temp as Event)
tempStartEndDateArray.removeAllObjects()
}
}
}
else if((fisrtDict["end"] as! NSDate).timeIntervalSinceDate(fisrtDict["start"] as! NSDate) > 0 )
{
tempStartEndDateArray.addObject(fisrtDict)
(event as! Event).eventSatrtEndDateRange.removeAllObjects()
let temp:Event = CreateTemporaryObject((event as! Event))
if ((event as! Event).savedEventsEndDates.count>0)
{
if ((event as! Event).savedEventsEndDates.containsObject(fisrtDict["end"] as! NSDate) == false)
{
temp.attending = ""
}
else
{
temp.attending = (event as! Event).attending
}
}
else
{
temp.attending = (event as! Event).attending
}
temp.eventStartDate = (tempStartEndDateArray[0]["start"] as! NSDate)
temp.eventEndDate = (tempStartEndDateArray[(tempStartEndDateArray.count-1)]["end"] as! NSDate)
temp.eventSatrtEndDateRange.addObjectsFromArray(tempStartEndDateArray as [AnyObject])
GroupObjectArray(temp)
tempStartEndDateArray.removeAllObjects()
}
i = i+1
}
}
else
{
GroupObjectArray(event as! Event)
}
}
if (result.count>0)
{
if (result.count>=10)
{
self.lastMemorisedDate = (result[(result.count-1)] as! Event).eventEndDate
}
else
{
self.lastMemorisedDate = nil
}
}
ShortArrayByDate()
}
func CreateTemporaryObject(event:Event) ->Event
{
let temp: Event = Event()
temp.hasEventTime=event.hasEventTime
temp.newForUser=event.newForUser
temp.name=event.name
temp.eventID=event.eventID
temp.imageURLString=event.imageURLString
temp.city=event.city
temp.venueID=event.venueID
temp.venueName=event.venueName
temp.distance=event.distance
temp.latitude=event.latitude
temp.savedEventsEndDates=event.savedEventsEndDates
temp.longitude=event.longitude
temp.eventDate=event.eventDate
// temp.eventEndDate=event.eventEndDate;
// temp.eventStartDate=event.eventStartDate;
// temp.attending=event.attending;
temp.trackbackUrlString=event.trackbackUrlString
temp.categories=event.categories
temp.artists=event.artists
temp.schedules=event.schedules
temp.friendsGoing=event.friendsGoing
temp.friendsWantTo=event.friendsWantTo
temp.friends=event.friends
temp.prices=event.prices
temp.currency=event.currency
temp.venue=event.venue
temp.eventDescription=event.eventDescription
temp.shortURLString=event.shortURLString
return temp
}
func ShortArrayByDate() ->Void
{
let sortDescriptor: NSSortDescriptor = NSSortDescriptor(key: "eventStartDate", ascending: true)
let sortDescriptors = [sortDescriptor]
let sortedArray:NSArray = eventHiddenArray.sortedArrayUsingDescriptors(sortDescriptors)
eventHiddenArray = sortedArray.mutableCopy() as! NSMutableArray
if (self.lastMemorisedDate != nil)
{
let pred = NSPredicate(format: "eventStartDate =< %@", lastMemorisedDate!)
let displayArray:NSArray = eventHiddenArray.filter { pred.evaluateWithObject($0) } ;
eventDisplayArray = displayArray.mutableCopy() as! NSMutableArray
}
else
{
self.eventDisplayArray = sortedArray.mutableCopy() as! NSMutableArray
}
}
func GroupObjectArray(event:Event)->Void
{
self.eventHiddenArray.addObject(event)
}
func GetFirstSlotEventStartEndDate(eventStartDateEndDateArray:NSMutableArray )->NSMutableArray
{
let tempStartEndDateArray = NSMutableArray();
var i:Int = 0
for fisrtDict in eventStartDateEndDateArray
{
let df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
if ((fisrtDict["start"] as! NSDate).isEqualToDate((fisrtDict ["end"] as! NSDate)))
{
tempStartEndDateArray.addObject(fisrtDict)
var currentDate: NSDate =
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…