We get a SIGBUS (BUS_ADRALN) and it points to this thread. What is causing this error? Line 68 is either NSString *dateString = [dateFormat stringFromDate:currentTimestamp]; or [dateFormat release];
NSDate *currentTimestamp = self.timestamp;
if (!currentTimestamp)
return nil; // sanity check
[currentTimestamp retain];
NSDateComponents *otherDay = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:currentTimestamp];
NSDateComponents *today = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:[NSDate date]];
NSDateComponents *yesterday = [[NSCalendar currentCalendar] components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:[[NSDate date] addTimeInterval: -24 * 60 * 60]];
if ([today day] == [otherDay day] &&
[today month] == [otherDay month] &&
[today year] == [otherDay year]) {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"h:mm a"];
NSString *dateString = [dateFormat stringFromDate:currentTimestamp];
[dateFormat release];
[currentTimestamp release];
return [NSString stringWithFormat:#"Today %#", dateString];
}
else if ([yesterday day] == [otherDay day] &&
[yesterday month] == [otherDay month] &&
[yesterday year] == [otherDay year]) {
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"h:mm a"];
NSString *dateString = [dateFormat stringFromDate:currentTimestamp];
[dateFormat release];
[currentTimestamp release];
return [NSString stringWithFormat:#"Yesterday %#", dateString];
}
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:#"MM/dd/yyyy h:mm a"];
// below is line 68
NSString *dateString = [dateFormat stringFromDate:currentTimestamp];
[dateFormat release];
[currentTimestamp release];
return dateString;
0 CoreFoundation 0x33474894 CFDateFormatterCreateStringWithAbsoluteTime + 60
1 CoreFoundation 0x33474817 CFDateFormatterCreateStringWithDate + 31
2 Foundation 0x326c4ad7 -[NSDateFormatter stringForObjectValue:] + 91
3 Foundation 0x326c4a75 -[NSDateFormatter stringFromDate:] + 21
4 MyApp 0x000a81dc -[Message getFormattedTimestamp] (Message.m:68)
5 MyApp 0x0007b7a4 -[ConversationView newBubble:withFrame:] (ConversationView.m:452)
6 MyApp 0x0007b2fc -[ConversationView tableView:heightForRowAtIndexPath:] (ConversationView.m:520)
7 UIKit 0x31bb3b09 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2173
8 UIKit 0x31bb3225 -[UITableViewRowData numberOfRows] + 73
9 UIKit 0x31bb2c73 -[UITableView noteNumberOfRowsChanged] + 83
10 UIKit 0x31bb27f7 -[UITableView reloadData] + 583
11 MyApp 0x0007cccc -[ConversationView reloadAndMoveToEnd:] (ConversationView.m:147)
12 MyApp 0x0007cc6c -[ConversationView managedObjectContext:fetchCompletedForRequest:withResults:error:] (ConversationView.m:153)
13 MyApp 0x00197670 -[IZManagedObjectContext backgroundFetchOperation:completedWithIDs:error:] (IZManagedObjectContext.m:150)
14 MyApp 0x001970b0 -[IZBackgroundFetchOperation fetchRequestDidCompleteWithUserInfo:] (IZBackgroundFetchOperation.m:108)
15 CoreFoundation 0x3347df03 -[NSObject(NSObject) performSelector:withObject:] + 23
16 Foundation 0x327237a9 __NSThreadPerformPerform + 269
17 CoreFoundation 0x334e7a79 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 13
18 CoreFoundation 0x334e975f __CFRunLoopDoSources0 + 383
19 CoreFoundation 0x334ea4eb __CFRunLoopRun + 231
20 CoreFoundation 0x3347aec3 CFRunLoopRunSpecific + 231
21 CoreFoundation 0x3347adcb CFRunLoopRunInMode + 59
22 GraphicsServices 0x311a541f GSEventRunModal + 115
23 GraphicsServices 0x311a54cb GSEventRun + 63
24 UIKit 0x31b90d69 -[UIApplication _run] + 405
25 UIKit 0x31b8e807 UIApplicationMain + 671
26 MyApp 0x0009b578 main (main.m:5)
Well, the code above is fine, as we ended up writing a unit test for it. Turns out it was a memory issue. Weird thing is it always pointed to this line.
Related
Recently my app got some crash report when convent NSData to NSString on ios10, the attachment image is the crash stack.The crash is collected by fabric and I can't reproduce it.
Does any one else met the same problem, Please tell me how to avoid the problem?
I have already checked the nsdata and ensure it is not nil.
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]
#0. Crashed: com.apple.main-thread
0 libsystem_kernel.dylib 0x18b7f3014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x18b8bb450 pthread_kill + 112
2 libsystem_c.dylib 0x18b767400 abort + 140
3 libsystem_malloc.dylib 0x18b837a5c _nano_vet_and_size_of_live + 330
4 libsystem_malloc.dylib 0x18b839028 nano_realloc + 648
5 libsystem_malloc.dylib 0x18b82b240 malloc_zone_realloc + 180
6 CoreFoundation 0x18c7e3958 __CFStringCreateImmutableFunnel3 + 692
7 CoreFoundation 0x18c76d81c CFStringCreateFromExternalRepresentation + 104
8 Foundation 0x18d253f64 -[NSPlaceholderString initWithData:encoding:] + 148
here is the crash detail screenshot
Check if your data is not nil and not Null
if (data && ![data isKindOfClass:[NSNull class]]) {
NSString *str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]
}
Check condition for NSData is not nil, data.length > 0 means it contains some value.
if(data.length > 0){
NSString *tempString =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//Do your tasks here
}
I have had a little search for this problem but cant seem to find a solution so hope you can help.
Basically I have built an app that saves a customers input data to a .csv file. Now I wish to display this information within the app but only the last entered user data (the other data of the users needs to be saved to the .csv but doesnt need to be viewed until later in a database) I can get it to load all the data but I only want the last submitted data displayed in the app... Here is my code so far;
-(IBAction)saveinfo:(id)sender{
NSString *resultLine=[NSString stringWithFormat:#"%# , %# , %# , %# , %# , %#, %#\n\n\n\n\n\n\n",
self.customername.text,
self.houseno.text,
self.customerpostcode.text,
self.catno.text,
_ordervalresult.text,
_reordervalresult.text,
self.date.text
];
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
//resultview.text = docPath;
NSString *surveys=[docPath stringByAppendingPathComponent:#"customerdata.csv"];
if (![[NSFileManager defaultManager] fileExistsAtPath:surveys]) {
[[NSFileManager defaultManager]
createFileAtPath:surveys contents:nil attributes:nil];
}
NSFileHandle *filehandle = [NSFileHandle fileHandleForUpdatingAtPath:surveys];
[filehandle seekToEndOfFile];
[filehandle writeData:[resultLine dataUsingEncoding:NSUTF8StringEncoding]];
[filehandle closeFile];
self.customername.text=#"";
self.houseno.text=#"";
self.customerpostcode.text=#"";
self.catno.text=#"";
self.date.text=#"";
_orderval.value=0;
_reorderval.value=0;
_ordervalresult.text=#"£0.00";
_reordervalresult.text=#"£0.00";
NSLog(#"surveys path: %#", surveys);
}
-(IBAction)retrieveinfo:(id)sender {
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
//resultView.text = docPath;
NSString *surveys=[docPath stringByAppendingPathComponent:#"customerdata.csv"];
if([[NSFileManager defaultManager] fileExistsAtPath: surveys])
{
NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:surveys];
NSString *surveyResults =[[NSString alloc]initWithData:[fileHandle availableData] encoding:NSUTF8StringEncoding];
[fileHandle closeFile];
self.resultview.text=surveyResults;
}
}
Anyone know how to tackle this? I have tried a few ideas but can either only load all the information or none at all...
Thank you for your time
EDIT: UPDATED CODE
-(IBAction)retrieveinfo:(id)sender {
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
_resultview.text = docPath;
NSString *surveys=[docPath stringByAppendingPathComponent:#"customerdata.csv"];
if([[NSFileManager defaultManager] fileExistsAtPath: surveys])
self.resultview.text=surveys;
//This is a part of your code from retrieveinfo:sender:
NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:surveys];
NSString *surveyResults =[[NSString alloc]initWithData:[fileHandle availableData] encoding:NSUTF8StringEncoding];
[fileHandle closeFile];
//All lines of you CSV file
NSArray *allLines = [surveyResults componentsSeparatedByString:#"\n"];
//To get Last Line
NSString *lastEntry = [allLines lastObject]; //or [allLines firstObject]; depending on the order your build it, but if I understood correctly it should be lastObject
NSArray *lastData = [lastEntry componentsSeparatedByString:#","];
NSString *lastCustomerName = [lastData objectAtIndex:0];
NSString *lastHouseNo = [lastData objectAtIndex:1];
NSString *lastCustomerPostcode = [lastData objectAtIndex:2];
I'd do this:
-(IBAction)pushRetrieveLastInfo:(id)sender
{
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *surveys=[docPath stringByAppendingPathComponent:#"customerdata.csv"];
if([[NSFileManager defaultManager] fileExistsAtPath: surveys])
{
NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:surveys];
NSString *surveyResults =[[NSString alloc]initWithData:[fileHandle availableData] encoding:NSUTF8StringEncoding];
[fileHandle closeFile];
//All lines of you CSV file
NSArray *allLines = [surveyResults componentsSeparatedByString:#"\n"];
//To get Last Line
NSString *lastEntry = [allLines lastObject]; //or [allLines firstObject]; depending on the order your build it, but if I understood correctly it should be lastObject
self.resultview.text=lastEntry;
}
}
Or:
-(IBAction)pushRetrieveLastInfo:(id)sender
{
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *surveys=[docPath stringByAppendingPathComponent:#"customerdata.csv"];
if([[NSFileManager defaultManager] fileExistsAtPath: surveys])
{
NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:surveys];
NSString *surveyResults =[[NSString alloc]initWithData:[fileHandle availableData] encoding:NSUTF8StringEncoding];
[fileHandle closeFile];
//All lines of you CSV file
NSArray *allLines = [surveyResults componentsSeparatedByString:#"\n"];
//To get Last Line
NSString *lastEntry = [allLines lastObject]; //or [allLines firstObject]; depending on the order your build it, but if I understood correctly it should be lastObject
NSArray *lastData = [lastEntry componentsSeparatedByString:#","];
NSString *lastCustomerName = [lastData objectAtIndex:0];
NSString *lastHouseNo = [lastData objectAtIndex:1];
NSString *lastCustomerPostcode = [lastData objectAtIndex:2];
NSString *lastCatNo = [lastData objectAtIndex:3];
NSString *lastOrderValResult = [lastData objectAtIndex:4];
NSString *lastReorderValResult = [lastData objectAtIndex:5];
NSString *lastDate = [lastData objectAtIndex:6];
NSString *textResult = [NSString stringWithFormat:#"Name: %#\nHouse Nb: %#\n, Last Postcode: %#\n, Last Cat Nb: %#\n, Last Order: %#\n, Last Reorder: %#\n, Last date: %#", lastCustomerName, lastHouseNo, lastCustomerPostcode, lastCatNo, lastOrderValResult, lastReorderValResult, lastDate];
self.resultview.text=textResult;
}
}
Seems that you could be also playing with the offset of the NSFileHandle, but it seems more complicated to me.
Error Message:
2014-09-10 17:37:53.888 Betterware - Database and Customer Information[15676:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x017f01e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0156f8e5 objc_exception_throw + 44
2 CoreFoundation 0x017a48b2 -[__NSArrayI objectAtIndex:] + 210
3 Betterware - Database and Customer Information 0x00002746 -[ViewController retrieveinfo:] + 726
4 libobjc.A.dylib 0x01581880 -[NSObject performSelector:withObject:withObject:] + 77
5 UIKit 0x002313b9 -[UIApplication sendAction:to:from:forEvent:] + 108
6 UIKit 0x00231345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
7 UIKit 0x00332bd1 -[UIControl sendAction:to:forEvent:] + 66
8 UIKit 0x00332fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
9 UIKit 0x00332243 -[UIControl touchesEnded:withEvent:] + 641
10 UIKit 0x00270ddd -[UIWindow _sendTouchesForEvent:] + 852
11 UIKit 0x002719d1 -[UIWindow sendEvent:] + 1117
12 UIKit 0x002435f2 -[UIApplication sendEvent:] + 242
13 UIKit 0x0022d353 _UIApplicationHandleEventQueue + 11455
14 CoreFoundation 0x0177977f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
15 CoreFoundation 0x0177910b __CFRunLoopDoSources0 + 235
16 CoreFoundation 0x017961ae __CFRunLoopRun + 910
17 CoreFoundation 0x017959d3 CFRunLoopRunSpecific + 467
18 CoreFoundation 0x017957eb CFRunLoopRunInMode + 123
19 GraphicsServices 0x037e45ee GSEventRunModal + 192
20 GraphicsServices 0x037e442b GSEventRun + 104
21 UIKit 0x0022ff9b UIApplicationMain + 1225
22 Betterware - Database and Customer Information 0x0000411d main + 141
23 libdyld.dylib 0x01e37701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I'm trying to get an NSMutableArray of NSDates each NSDate object targets the nearest rounded either HH:00 or HH:30 for the next 24 hours from now.
lets say right now its 02:31 I want an output of #[03:00,03:30,04:00,04:30...03:00(of the next day)]
if its 02:29 then I want #[02:30,03:00 and so on till the next day at 02:30].
right now I have the code below and it works almost all the time, yet rarely I get an output of all the NSDate objects that I want with a remainder of an extra minute(#[03:01,03:31:04:01...so on]).
any ideas ?
-(NSMutableArray*)TwentyFourHoursFromNowDivicedBy30Mins
{
NSMutableArray * dateArray = [NSMutableArray array];
NSCalendar * cal = [NSCalendar currentCalendar];
NSDateComponents * plusDays = [NSDateComponents new];
NSDate * now = [self changeTimeValue:[NSDate date]];
for( NSUInteger day = 0; day < 2; day++ )
{
[plusDays setDay:day];
[dateArray addObject:[cal dateByAddingComponents:plusDays toDate:now options:0]];
}
NSDate *startDate = [dateArray objectAtIndex:0];
NSDate *endDate = [dateArray objectAtIndex:1];
NSDateComponents *diff = [[NSDateComponents alloc] init];
[diff setMinute:0];
NSCalendar *calz = [NSCalendar currentCalendar];
NSDate *tmp = startDate;
NSMutableArray *dates = [NSMutableArray arrayWithObject:tmp];
while ([tmp laterDate:endDate] == endDate) {
[diff setMinute:[diff minute] + 30];
tmp = [calz dateByAddingComponents:diff toDate:startDate options:0];
[dates addObject:tmp];
}
return dates;
}
- (NSDate *)changeTimeValue:(NSDate *)dateValue{
NSDateComponents *time = [[NSCalendar currentCalendar]
components:NSHourCalendarUnit | NSMinuteCalendarUnit
fromDate:dateValue];
long val = 0;
NSDate *newDate = [[NSDate alloc] init];
NSInteger minutes = [time minute];
if(minutes > 0 && minutes < 30) {
val = 30 - minutes; NSTimeInterval aTimeInterval = [dateValue
timeIntervalSinceReferenceDate] + 60 * val + minutes;
newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval];
return newDate;
} else if(minutes > 30 && minutes < 60) {
val = 60 - minutes;
NSTimeInterval aTimeInterval = [dateValue timeIntervalSinceReferenceDate]
+ 60 * val;
newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval];
return newDate;
} else {
return newDate;
}
}
You're not zeroing out the seconds in your changeTimeValue, and in any case I think you've overcomplicated it. So I suspect you're subsequently seeing rounding issues. Just use NSDateComponents to do the whole job:
NSCalendar *currentCalendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponents = [currentCalendar
components:NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSYearCalendarUnit |
NSMonthCalendarUnit |
NSDayCalendarUnit
fromDate:dateValue];
dateComponents.minute += 15;
dateComponents.minute -= dateComponents.minute%30;
return [currentCalendar dateFromComponents:dateComponents];
I am trying to execute a command for creating a Cordova Project in my Cocoa Desktop App but It doesn't work.
That's my code:
NSTask *task = [NSTask new];
[task setLaunchPath:#"/Documents/Cordova/bin/ ./create ~/Documents/Cordova/HelloWorld2 org.apache.cordova.HelloWorld2 HelloWorld2"];
[task setArguments:[NSArray arrayWithObjects:#"-l", #"-a", #"-t", nil]];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
NSData *data = [[pipe fileHandleForReading] readDataToEndOfFile];
[task waitUntilExit];
// [task release];
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog (#"got\n%#", string);
And that's output:
2013-04-02 23:48:18.968 Phonegap-ProjectCreator[2209:303] launch path not accessible
2013-04-02 23:48:18.970 Phonegap-ProjectCreator[2209:303] (
0 CoreFoundation 0x00007fff8b2b80a6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff88d7e3f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8b2b7e7c +[NSException raise:format:] + 204
3 Foundation 0x00007fff8bd21cd2 -[NSConcreteTask launchWithDictionary:] + 409
4 Phonegap-ProjectCreator 0x0000000100002a4a -[MainWindow createProject:] + 314
5 AppKit 0x00007fff94506a59 -[NSApplication sendAction:to:from:] + 342
6 AppKit 0x00007fff945068b7 -[NSControl sendAction:to:] + 85
7 AppKit 0x00007fff945067eb -[NSCell _sendActionFrom:] + 138
8 AppKit 0x00007fff94504cd3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
9 AppKit 0x00007fff94504521 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
10 AppKit 0x00007fff94503c9c -[NSControl mouseDown:] + 820
11 AppKit 0x00007fff944fb60e -[NSWindow sendEvent:] + 6853
12 AppKit 0x00007fff944f7744 -[NSApplication sendEvent:] + 5761
13 AppKit 0x00007fff9440d2fa -[NSApplication run] + 636
14 AppKit 0x00007fff943b1cb6 NSApplicationMain + 869
15 Phonegap-ProjectCreator 0x00000001000011d2 main + 34
16 libdyld.dylib 0x00007fff89ced7e1 start + 0
17 ??? 0x0000000000000003 0x0 + 3
)
I don't understand what is the problem? It can't find path for executing or can't execute?
The launch path is the path to be launched, not the command line to be invoked. It should only contain the path to the executable to be run.
The arguments array is the arguments that should be passed. You are mixing the two.
Your executable looks to be "/Documents/Cordova/bin/create"
Arguments appear to be something like:
NSArray *args = #["-l", "~/Documents/Cordova/HelloWorld2", "-a", "org.apache.cordova.HelloWorld2", "-t", "HelloWorld2"];
I.e. arguments have values and the values are interleaved with the arguments in the arguments array.
I found the solution. I am new to objective c and I realized I made a lot of mistake.
That's the solution:
/** Path to Application **/
NSString *path = #"/Users/username/Documents/Cordova/bin/create";
/** Arguments **/
NSArray *args = [NSArray arrayWithObjects:#"/Users/username/Documents/Cordova/HelloWorld3",#"org.apache.cordova.HelloWorld3",#"HelloWorld3", nil];
[[NSTask launchedTaskWithLaunchPath:path arguments:args] waitUntilExit];
How can I get an array of days of current week?
For example - today is saturday - 28 july.
I need array with '28 Saturday', 27 Friday, 26 Thursday,25 Wednesday ... 22 Sunday?
[code] NSCalendar *myCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *currentComps = [myCalendar components:( NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekOfYearCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:weekDate];
int ff = currentComps.weekOfYear;
NSLog(#"1 %d", ff);
[currentComps setWeekday:1]; // 1: sunday
NSDate *firstDayOfTheWeek = [myCalendar dateFromComponents:currentComps];
[currentComps setWeekday:7]; // 7: saturday
NSDate *lastDayOfTheWeek = [myCalendar dateFromComponents:currentComps];
NSLog(#"first - %# \nlast - %#", firstDayOfTheWeek, lastDayOfTheWeek); [code]
I did this, but I have 'firstDayOfWeek' - 2012-07-29 and 'lastDayOfWeek' - 2012-08-04
Here is what you're looking for - you just need to format the result accordingly:
NSDate *weekDate = [NSDate date];
NSCalendar *myCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *currentComps = [myCalendar components:( NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekOfYearCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:weekDate];
int ff = currentComps.weekOfYear;
NSLog(#"1 %d", ff);
[currentComps setWeekday:1]; // 1: sunday
NSDate *firstDayOfTheWeek = [myCalendar dateFromComponents:currentComps];
[currentComps setWeekday:7]; // 7: saturday
NSDate *lastDayOfTheWeek = [myCalendar dateFromComponents:currentComps];
NSDateFormatter *myDateFormatter = [[NSDateFormatter alloc] init];
myDateFormatter.dateFormat = #"dd EEEE";
NSString *firstStr = [myDateFormatter stringFromDate:firstDayOfTheWeek];
NSString *secondStr = [myDateFormatter stringFromDate:lastDayOfTheWeek];
NSLog(#"first - %# \nlast - %#", firstStr, secondStr);