Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "TodayViewController.h"
- #import <NotificationCenter/NotificationCenter.h>
- @interface TodayViewController () <NCWidgetProviding>
- @end
- @implementation TodayViewController
- - (void)getDLNumber {
- NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"URL withheld"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0];
- NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
- if (connection) {
- label.stringValue = @"Connecting...";
- } else {
- }
- }
- - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
- response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
- }
- - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
- //Cleans up string and returns just the number
- NSString *newString = [[response componentsSeparatedByCharactersInSet:
- [[NSCharacterSet characterSetWithCharactersInString:@"0123456789,"] invertedSet]]
- componentsJoinedByString:@""];
- label.stringValue = newString;
- }
- - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult result))completionHandler {
- // Update your data and prepare for a snapshot. Call completion handler when you are done
- // with NoData if nothing has changed or NewData if there is new data since the last
- // time we called you
- completionHandler(NCUpdateResultNoData);
- [self getDLNumber];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement