Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

learningGit #463

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions MKNetworkKit/Categories/UIAlertView+MKNetworkKitAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if TARGET_OS_IPHONE
#if !TARGET_IS_EXTENSION
#import "UIAlertView+MKNetworkKitAdditions.h"

@implementation UIAlertView (MKNetworkKitAdditions)
Expand All @@ -39,3 +40,4 @@ +(UIAlertView*) showWithError:(NSError*) networkError {
}
@end
#endif
#endif
2 changes: 2 additions & 0 deletions MKNetworkKit/MKNetworkEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ + (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
[[NSNotificationCenter defaultCenter] postNotificationName:kMKNetworkEngineOperationCountChanged
object:[NSNumber numberWithInteger:(NSInteger)[_sharedNetworkQueue operationCount]]];
#if TARGET_OS_IPHONE
#if !TARGET_IS_EXTENSION
[UIApplication sharedApplication].networkActivityIndicatorVisible =
([_sharedNetworkQueue.operations count] > 0);
#endif
#endif
}
else {
Expand Down
8 changes: 8 additions & 0 deletions MKNetworkKit/MKNetworkOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -890,19 +890,22 @@ -(void) main {
-(void) endBackgroundTask {

#if TARGET_OS_IPHONE
#if !TARGET_IS_EXTENSION
dispatch_async(dispatch_get_main_queue(), ^{
if (self.backgroundTaskId != UIBackgroundTaskInvalid) {
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskId];
self.backgroundTaskId = UIBackgroundTaskInvalid;
}
});
#endif
#endif
}

- (void) start
{

#if TARGET_OS_IPHONE
#if !TARGET_IS_EXTENSION
self.backgroundTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{

dispatch_async(dispatch_get_main_queue(), ^{
Expand All @@ -915,6 +918,7 @@ - (void) start
});
}];

#endif
#endif

if(!self.isCancelled) {
Expand Down Expand Up @@ -1482,6 +1486,7 @@ -(void) operationSucceeded {

-(void) showLocalNotification {
#if TARGET_OS_IPHONE
#if !TARGET_IS_EXTENSION

if(self.localNotification) {

Expand All @@ -1496,6 +1501,7 @@ -(void) showLocalNotification {
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
}
#endif
#endif
}

-(void) operationFailedWithError:(NSError*) error {
Expand All @@ -1509,9 +1515,11 @@ -(void) operationFailedWithError:(NSError*) error {
errorBlock(self, error);

#if TARGET_OS_IPHONE
#if !TARGET_IS_EXTENSION
if([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground)
[self showLocalNotification];
#endif
#endif

}

Expand Down
1 change: 1 addition & 0 deletions README.mdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
加一个测试
This is version 0.87 of MKNetworkKit. Read the [blog post](http://mk.sg/8w) for more. The latest code is still not fully testing on Mac, though iOS is complete. Caching responses and invalidation of cache is not implemented the right way for the Mac target.

MKNetworkKit is ready for production use on iOS apps. As on date, it's used by several thousands of apps including [Digg](https://itunes.apple.com/us/app/digg/id362872995?mt=8)
Expand Down