четверг, 15 октября 2015 г.

Font names in iOS

Might be interesting for you as Quick Win within the Debugger:
(lldb) po [UIFont fontNamesForFamilyName:@"Helvetica Neue"]

(id) $1 = 0x079d8670 <__NSCFArray 0x79d8670>(
HelveticaNeue-Bold,
HelveticaNeue-CondensedBlack,
HelveticaNeue-Medium,
HelveticaNeue,
HelveticaNeue-Light,
HelveticaNeue-CondensedBold,
HelveticaNeue-LightItalic,
HelveticaNeue-UltraLightItalic,
HelveticaNeue-UltraLight,
HelveticaNeue-BoldItalic,
HelveticaNeue-Italic
)
source: http://stackoverflow.com/questions/11083954/uifont-fontwithname-font-name

вторник, 13 октября 2015 г.

Pull to refresh swift


var refresher: UIRefreshControl!

    override func viewDidLoad() {
        super.viewDidLoad()
//...
        initRefresher()
    }
    
    // MARK: Helper
    func initRefresher() {
        refresher = UIRefreshControl()
        refresher.attributedTitle = NSAttributedString(string: "Потяните вниз для обновления")
        refresher.addTarget(self, action: "refreshData", forControlEvents: UIControlEvents.ValueChanged)
        tableView.addSubview(refresher)
        

    }


    
    func refreshData() {
//... обновляемся
    refresher.endRefreshing() //выключаем обновление
    }

Хорошая статья: pull to refresh

Core Data NSPredicate checking for BOOL value

Based on Apple Document Here, we can use the following two methods to compare Boolean:
NSPredicate *newPredicate = [NSPredicate predicateWithFormat:@"anAttribute == %@",[NSNumber numberWithBool:aBool]];
NSPredicate *testForTrue = [NSPredicate predicateWithFormat:@"anAttribute == YES"];
However, the above predicate cannot get out the ones with empty anAttribute. To deal with an empty attribute, you need the following method according to Apple document here:
predicate = [NSPredicate predicateWithFormat:@"firstName = nil"]; // it's in the document
or
predicate = [NSPredicate predicateWithFormat:@"firstName == nil"]; // == and = are interchangeable here

Corner Radius

import QuartzCore
...
view.layer.cornerRadius = 5;
view.layer.masksToBounds = YES;