Deleting from Core Data

Deleting objects from Core Data should not be recognized as deleting rows from SQLite table. It is like deleting objects from Object Graph. This is an example of deleting all rows for the current file number. I retrieve all NSManagedObject objects and delete them in cycle.

+ (BOOL)deleteScrollPositionsForFileNumber:(NSInteger)fileNumber {
    BOOL success;
    NSManagedObjectContext *context = appDelegate.managedObjectContext;
    if (context == nil) {
        NSLog(@"Error: No context");
        success = NO;
        return success;
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"fileNumber == %d", fileNumber];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"ScrollPosition" inManagedObjectContext:context];
    [fetchRequest setEntity:entity];
    [fetchRequest setPredicate:predicate];
    NSError *error = nil;
    NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
    NSLog(@"Number of deleted objects: %d", [fetchedObjects count]);
    for (NSManagedObject *object in fetchedObjects) {
        [context deleteObject:object];
    success = YES;
    return success;

Change MBProgressHUD color

To change the background color of MBProgressHUD comment this line and add this in MBProgressHUD.m in drawRect method:

This code changes HUD color to blue.

Reload UITableView cells

Sometimes it’s needed to reload only some of the rows of UITableView to save some time and energy and not reload whole the table. This is how it can be done:

Save current position in UIScrollView and then scroll to this position

To save a position of the current scroll view use this method:

To scroll programmatically to the saved position use this method:

How to build MailCore framework on iOS

MailCore is a Cocoa e-mail framework built by Matt Ronge that is the core of the e-mail client Kiwi. MailCore provides a nice set of objects for working with IMAP, MIME and SMTP, all of which use the C e-mail library LibEtPan. Here is some short information about MailCore. This is short documentation on MailCore from Matt Ronge. Official website is here.

To make it run on your iOS simulator, do the following:

  1. Download MailCore from GitHub:
  2. Build m4, autoconf, automake, libtool on Mac OS X Lion using this post.
  3. Run script in MailCore to build and install everything before opening it in Xcode. If you don’t know, how to run shell scripts, read this
  4. Open MessageSender project in MailCore library. Select MessageSender to build. It will not do anything. To make it sending a test message write the following code in ViewDidLoad:
  5. Use this method to retrieve message subjects from Inbox of your mail:

Official MailCore website.

What’s new in iOS 6: developer-related features

This is the link for Apple Developers.

Brief content (developer-related features):

iOS 6.0

In addition to the new map tiles provided by Apple, the Maps app and MapKit framework now support additional interactions with other apps.

Social Framework
The Social framework (Social.framework) provides a simple interface for accessing the user’s social media accounts.

Pass Kit
Pass Kit is a new technology that uses web services, a new file format, and an Objective-C framework (PassKit.framework) to implement support for downloadable passes.

Game Center
Game Center has been updated and new features have been added to improve the game playing experience.

The Event Kit framework now includes interfaces for creating and accessing reminders on the user’s device.

In-App Purchase
The Store Kit framework (StoreKit.framework) now supports the purchasing of iTunes content inside your app and provides support for having downloadable content hosted on Apple servers

Collection Views
The UICollectionView class offers a new way to present ordered data to users. With a collection view object, you are now able to define the presentation and arrangement of embedded views

UI State Preservation
State preservation makes it easier for apps to restore their user interface to the state it was in when the user last used it.

Auto Layout
Auto layout improves upon the “springs and struts” model previously used to lay out the elements of a user interface. With auto layout, you define rules for how to lay out the elements in your user interface.

Data Privacy
In addition to location data, the system now asks the user’s permission before allowing third-party apps to access certain user data

Additional Framework Enhancements

Добавление и переход на номер строки в Vim

Чтобы добавить номер строки в редакторе Vim, напишите следующее:

перед тем как зайти в режим редактирования. (там же, где пишете :wq, чтобы выйти)

Чтобы сразу перейти к определенной строке (с ошибкой, например), напишите:

Здесь 31 – номер строки, – редактируемый файл (Perl)

Delete files by mask in Bash (Terminal)

Go to the folder, where you want to delete for instance all mp3 files in this folder and it’s subfolders and type this:

If you want to delete files by mask only in current folder, type this:

Creating Local SVN Repository for Project


2. While in the project folder:

3. Create a project folder:

4. Go to the documents folder:

5. Check out from repository: