ソースを参照

Enabling and fixing extensive compiler warnings

Mattt Thompson 12 年 前
コミット
09658b352a

+ 2 - 2
AFNetworking/AFHTTPRequestOperation.m

@@ -105,9 +105,9 @@ static dispatch_group_t http_request_operation_completion_group() {
 - (void)pause {
     int64_t offset = 0;
     if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) {
-        offset = [[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue];
+        offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] longLongValue];
     } else {
-        offset = [[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length];
+        offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length];
     }
 
     NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy];

+ 2 - 2
AFNetworking/AFSecurityPolicy.m

@@ -78,7 +78,7 @@ static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) {
 
 static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) {
     CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
-    NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:certificateCount];
+    NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
 
     for (CFIndex i = 0; i < certificateCount; i++) {
         SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
@@ -91,7 +91,7 @@ static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust)
 static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) {
     SecPolicyRef policy = SecPolicyCreateBasicX509();
     CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
-    NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:certificateCount];
+    NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];
     for (CFIndex i = 0; i < certificateCount; i++) {
         SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
 

+ 2 - 2
AFNetworking/AFURLConnectionOperation.m

@@ -600,12 +600,12 @@ didReceiveResponse:(NSURLResponse *)response
 {
     NSUInteger length = [data length];
     while (YES) {
-        NSUInteger totalNumberOfBytesWritten = 0;
+        NSInteger totalNumberOfBytesWritten = 0;
         if ([self.outputStream hasSpaceAvailable]) {
             const uint8_t *dataBuffer = (uint8_t *)[data bytes];
 
             NSInteger numberOfBytesWritten = 0;
-            while (totalNumberOfBytesWritten < length) {
+            while (totalNumberOfBytesWritten < (NSInteger)length) {
                 numberOfBytesWritten = [self.outputStream write:&dataBuffer[0] maxLength:length];
                 if (numberOfBytesWritten == -1) {
                     [self.connection cancel];

+ 2 - 3
AFNetworking/AFURLRequestSerialization.h

@@ -30,7 +30,7 @@
 
  For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`.
  */
-@protocol AFURLRequestSerialization <NSCoding, NSCopying>
+@protocol AFURLRequestSerialization <NSObject, NSCoding, NSCopying>
 
 /**
  Returns a request with the specified parameters encoded into a copy of the original request.
@@ -87,7 +87,7 @@ typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) {
 /**
  Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header.
 
- @param header The HTTP header to set a default value for
+ @param field The HTTP header to set a default value for
  @param value The value set as default for the specified header, or `nil`
  */
 - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
@@ -313,7 +313,6 @@ extern NSTimeInterval const kAFUploadStream3GSuggestedDelay;
 /**
  Creates and returns a JSON serializer with specified reading and writing options.
 
- @param readingOptions The specified JSON reading options.
  @param writingOptions The specified JSON writing options.
  */
 + (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions;

+ 6 - 3
AFNetworking/AFURLRequestSerialization.m

@@ -107,7 +107,7 @@ static NSString * AFPercentEscapedQueryStringValueFromStringWithEncoding(NSStrin
 extern NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary);
 extern NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value);
 
-NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding stringEncoding) {
+static NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding stringEncoding) {
     NSMutableArray *mutablePairs = [NSMutableArray array];
     for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) {
         [mutablePairs addObject:[pair URLEncodedStringValueWithEncoding:stringEncoding]];
@@ -680,6 +680,8 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
 
     NSInteger totalNumberOfBytesRead = 0;
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
     while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) {
         if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) {
             if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) {
@@ -700,6 +702,7 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
             }
         }
     }
+#pragma clang diagnostic pop
 
     return totalNumberOfBytesRead;
 }
@@ -899,7 +902,7 @@ typedef enum {
 - (NSInteger)read:(uint8_t *)buffer
         maxLength:(NSUInteger)length
 {
-    NSUInteger totalNumberOfBytesRead = 0;
+    NSInteger totalNumberOfBytesRead = 0;
 
     if (_phase == AFEncapsulationBoundaryPhase) {
         NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding];
@@ -1110,7 +1113,7 @@ typedef enum {
     [super encodeWithCoder:aCoder];
 
     [aCoder encodeInteger:self.format forKey:@"format"];
-    [aCoder encodeInteger:self.writeOptions forKey:@"writeOptions"];
+    [aCoder encodeInteger:(NSInteger)self.writeOptions forKey:@"writeOptions"];
 }
 
 #pragma mark - NSCopying

+ 1 - 3
AFNetworking/AFURLResponseSerialization.h

@@ -28,7 +28,7 @@
 
  For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object.
  */
-@protocol AFURLResponseSerialization <NSCoding, NSCopying>
+@protocol AFURLResponseSerialization <NSObject, NSCoding, NSCopying>
 
 /**
  The response object decoded from the data associated with a specified response.
@@ -119,7 +119,6 @@
  Creates and returns a JSON serializer with specified reading and writing options.
 
  @param readingOptions The specified JSON reading options.
- @param writingOptions The specified JSON writing options.
  */
 + (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions;
 
@@ -195,7 +194,6 @@
 
  @param format The property list format.
  @param readOptions The property list reading options.
- @param writeOptions The property list write options.
  */
 + (instancetype)serializerWithFormat:(NSPropertyListFormat)format
                          readOptions:(NSPropertyListReadOptions)readOptions;

+ 3 - 3
AFNetworking/AFURLResponseSerialization.m

@@ -58,7 +58,7 @@ extern NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
                    error:(NSError *__autoreleasing *)error
 {
     if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
-        if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:response.statusCode]) {
+        if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode]) {
             NSDictionary *userInfo = @{
                                        NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%d), got %d", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], response.statusCode],
                                        NSURLErrorFailingURLErrorKey:[response URL],
@@ -413,7 +413,7 @@ extern NSString * const AFNetworkingOperationFailingURLResponseErrorKey;
     [super encodeWithCoder:aCoder];
 
     [aCoder encodeInteger:self.format forKey:@"format"];
-    [aCoder encodeInteger:self.readOptions forKey:@"readOptions"];
+    [aCoder encodeInteger:(NSInteger)self.readOptions forKey:@"readOptions"];
 }
 
 #pragma mark - NSCopying
@@ -638,7 +638,7 @@ static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *r
                            data:(NSData *)data
                           error:(NSError *__autoreleasing *)error
 {
-    for (id serializer in self.responseSerializers) {
+    for (id <AFURLResponseSerialization> serializer in self.responseSerializers) {
         if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
             continue;
         }

+ 11 - 6
AFNetworking/AFURLSessionManager.m

@@ -133,11 +133,15 @@ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
               task:(NSURLSessionTask *)task
 didCompleteWithError:(NSError *)error
 {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
     if (self.completionHandler) {
+        __strong AFURLSessionManager *manager = self.manager;
+
         __block id responseObject = nil;
 
         __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
-        userInfo[AFNetworkingTaskDidFinishResponseSerializerKey] = self.manager.responseSerializer;
+        userInfo[AFNetworkingTaskDidFinishResponseSerializerKey] = manager.responseSerializer;
 
         if (self.downloadFileURL) {
             userInfo[AFNetworkingTaskDidFinishAssetPathKey] = self.downloadFileURL;
@@ -148,7 +152,7 @@ didCompleteWithError:(NSError *)error
         if (error) {
             userInfo[AFNetworkingTaskDidFinishErrorKey] = error;
 
-            dispatch_group_async(self.manager.completionGroup ?: url_session_manager_completion_group(), self.manager.completionQueue ?: dispatch_get_main_queue(), ^{
+            dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
                 if (self.completionHandler) {
                     self.completionHandler(task.response, responseObject, error);
                 }
@@ -161,7 +165,7 @@ didCompleteWithError:(NSError *)error
                 if (self.downloadFileURL) {
                     responseObject = self.downloadFileURL;
                 } else {
-                    responseObject = [self.manager.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError];
+                    responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError];
                 }
 
                 if (responseObject) {
@@ -172,7 +176,7 @@ didCompleteWithError:(NSError *)error
                     userInfo[AFNetworkingTaskDidFinishErrorKey] = serializationError;
                 }
 
-                dispatch_group_async(self.manager.completionGroup ?: url_session_manager_completion_group(), self.manager.completionQueue ?: dispatch_get_main_queue(), ^{
+                dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{
                     if (self.completionHandler) {
                         self.completionHandler(task.response, responseObject, serializationError);
                     }
@@ -182,6 +186,7 @@ didCompleteWithError:(NSError *)error
             });
         }
     }
+#pragma clang diagnostic pop
 }
 
 #pragma mark - NSURLSessionDataTaskDelegate
@@ -228,8 +233,8 @@ totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
 
 - (void)URLSession:(__unused NSURLSession *)session
       downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask
- didResumeAtOffset:(__unused int64_t)fileOffset
-expectedTotalBytes:(__unused int64_t)expectedTotalBytes {
+ didResumeAtOffset:(int64_t)fileOffset
+expectedTotalBytes:(int64_t)expectedTotalBytes {
     self.downloadProgress.completedUnitCount = fileOffset;
     self.downloadProgress.totalUnitCount = expectedTotalBytes;
 }

+ 54 - 0
Example/AFNetworking iOS Example.xcodeproj/project.pbxproj

@@ -491,13 +491,40 @@
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
+				CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
+				CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+				CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+				CLANG_WARN_OBJC_RECEIVER_WEAK = NO;
+				CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
+				CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = Prefix.pch;
+				GCC_SHORT_ENUMS = YES;
+				GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
+				GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
+				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+				GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
+				GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO;
+				GCC_WARN_PEDANTIC = YES;
 				GCC_WARN_SHADOW = YES;
 				GCC_WARN_SIGN_COMPARE = YES;
+				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNKNOWN_PRAGMAS = YES;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_LABEL = YES;
 				GCC_WARN_UNUSED_PARAMETER = YES;
 				INFOPLIST_FILE = "iOS-Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 7.0;
@@ -512,12 +539,39 @@
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
 				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES;
+				CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES;
+				CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
+				CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+				CLANG_WARN_OBJC_RECEIVER_WEAK = NO;
+				CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
+				CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = YES;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = Prefix.pch;
+				GCC_SHORT_ENUMS = YES;
+				GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
+				GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
+				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
+				GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+				GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
+				GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO;
+				GCC_WARN_PEDANTIC = YES;
 				GCC_WARN_SHADOW = YES;
 				GCC_WARN_SIGN_COMPARE = YES;
+				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNKNOWN_PRAGMAS = YES;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_LABEL = YES;
 				GCC_WARN_UNUSED_PARAMETER = YES;
 				INFOPLIST_FILE = "iOS-Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 7.0;

+ 7 - 8
Example/Classes/Controllers/GlobalTimelineViewController.m

@@ -30,20 +30,19 @@
 #import "UIAlertView+AFNetworking.h"
 
 @interface GlobalTimelineViewController ()
+@property (readwrite, nonatomic, strong) NSArray *posts;
+
 - (void)reload:(id)sender;
 @end
 
-@implementation GlobalTimelineViewController {
-@private
-    NSArray *_posts;
-}
+@implementation GlobalTimelineViewController
 
 - (void)reload:(__unused id)sender {
     self.navigationItem.rightBarButtonItem.enabled = NO;
 
     NSURLSessionTask *task = [Post globalTimelinePostsWithBlock:^(NSArray *posts, NSError *error) {
         if (!error) {
-            _posts = posts;
+            self.posts = posts;
             [self.tableView reloadData];
         }
         
@@ -77,7 +76,7 @@
 - (NSInteger)tableView:(__unused UITableView *)tableView
  numberOfRowsInSection:(__unused NSInteger)section
 {
-    return [_posts count];
+    return (NSInteger)[self.posts count];
 }
 
 - (UITableViewCell *)tableView:(UITableView *)tableView
@@ -90,7 +89,7 @@
         cell = [[PostTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
     }
     
-    cell.post = [_posts objectAtIndex:indexPath.row];
+    cell.post = [self.posts objectAtIndex:(NSUInteger)indexPath.row];
     
     return cell;
 }
@@ -100,7 +99,7 @@
 - (CGFloat)tableView:(__unused UITableView *)tableView
 heightForRowAtIndexPath:(NSIndexPath *)indexPath
 {
-    return [PostTableViewCell heightForCellWithPost:[_posts objectAtIndex:indexPath.row]];
+    return [PostTableViewCell heightForCellWithPost:[self.posts objectAtIndex:(NSUInteger)indexPath.row]];
 }
 
 - (void)tableView:(UITableView *)tableView

+ 3 - 3
Example/Classes/Models/Post.h

@@ -26,10 +26,10 @@
 
 @interface Post : NSObject
 
-@property (assign) NSUInteger postID;
-@property (strong) NSString *text;
+@property (nonatomic, assign) NSUInteger postID;
+@property (nonatomic, strong) NSString *text;
 
-@property (strong) User *user;
+@property (nonatomic, strong) User *user;
 
 - (instancetype)initWithAttributes:(NSDictionary *)attributes;
 

+ 2 - 2
Example/Classes/Models/User.h

@@ -26,8 +26,8 @@ extern NSString * const kUserProfileImageDidLoadNotification;
 
 @interface User : NSObject
 
-@property (readonly, nonatomic) NSUInteger userID;
-@property (readonly, nonatomic) NSString *username;
+@property (readonly, nonatomic, assign) NSUInteger userID;
+@property (readonly, nonatomic, copy) NSString *username;
 @property (readonly, nonatomic, unsafe_unretained) NSURL *avatarImageURL;
 
 - (instancetype)initWithAttributes:(NSDictionary *)attributes;

+ 12 - 11
Example/Classes/Models/User.m

@@ -25,17 +25,18 @@
 
 NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded";
 
-#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
 @interface User ()
+@property (readwrite, nonatomic, assign) NSUInteger userID;
+@property (readwrite, nonatomic, copy) NSString *username;
+@property (readwrite, nonatomic, copy) NSString *avatarImageURLString;
+@property (readwrite, nonatomic, strong) AFHTTPRequestOperation *avatarImageRequestOperation;
+
+#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
 + (NSOperationQueue *)sharedProfileImageRequestOperationQueue;
-@end
 #endif
+@end
 
-@implementation User {
-@private
-    NSString *_avatarImageURLString;
-    AFHTTPRequestOperation *_avatarImageRequestOperation;
-}
+@implementation User
 
 - (instancetype)initWithAttributes:(NSDictionary *)attributes {
     self = [super init];
@@ -43,15 +44,15 @@ NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.pro
         return nil;
     }
     
-    _userID = [[attributes valueForKeyPath:@"id"] integerValue];
-    _username = [attributes valueForKeyPath:@"username"];
-    _avatarImageURLString = [attributes valueForKeyPath:@"avatar_image.url"];
+    self.userID = [[attributes valueForKeyPath:@"id"] integerValue];
+    self.username = [attributes valueForKeyPath:@"username"];
+    self.avatarImageURLString = [attributes valueForKeyPath:@"avatar_image.url"];
     
     return self;
 }
 
 - (NSURL *)avatarImageURL {
-    return [NSURL URLWithString:_avatarImageURLString];
+    return [NSURL URLWithString:self.avatarImageURLString];
 }
 
 //#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED

+ 2 - 2
Example/Classes/Views/PostTableViewCell.m

@@ -59,7 +59,7 @@
 + (CGFloat)heightForCellWithPost:(Post *)post {
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
-    CGSize sizeToFit = [post.text sizeWithFont:[UIFont systemFontOfSize:12.0f] constrainedToSize:CGSizeMake(220.0f, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
+    CGSize sizeToFit = [post.text sizeWithFont:[UIFont systemFontOfSize:12.0f] constrainedToSize:CGSizeMake(220.0f, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
 #pragma clang diagnostic pop
     
     return fmaxf(70.0f, sizeToFit.height + 45.0f);
@@ -74,7 +74,7 @@
     self.textLabel.frame = CGRectMake(70.0f, 10.0f, 240.0f, 20.0f);
     
     CGRect detailTextLabelFrame = CGRectOffset(self.textLabel.frame, 0.0f, 25.0f);
-    detailTextLabelFrame.size.height = [[self class] heightForCellWithPost:_post] - 45.0f;
+    detailTextLabelFrame.size.height = [[self class] heightForCellWithPost:self.post] - 45.0f;
     self.detailTextLabel.frame = detailTextLabelFrame;
 }
 

+ 1 - 1
Example/Prefix.pch

@@ -17,4 +17,4 @@
     #import <SystemConfiguration/SystemConfiguration.h>
     #import <CoreServices/CoreServices.h>
   #endif
-#endif
+#endif

+ 4 - 4
UIKit+AFNetworking/UIAlertView+AFNetworking.h

@@ -38,13 +38,13 @@
 
  */
 + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
-                                         delegate:(id /*<UIAlertViewDelegate>*/)delegate;
+                                         delegate:(id)delegate;
 
 /**
  
  */
 + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
-                                         delegate:(id /*<UIAlertViewDelegate>*/)delegate
+                                         delegate:(id)delegate
                                 cancelButtonTitle:(NSString *)cancelButtonTitle
                                 otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
 
@@ -57,13 +57,13 @@
  
  */
 + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
-                                                     delegate:(id /*<UIAlertViewDelegate>*/)delegate;
+                                                     delegate:(id)delegate;
 
 /**
  
  */
 + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
-                                                     delegate:(id /*<UIAlertViewDelegate>*/)delegate
+                                                     delegate:(id)delegate
                                             cancelButtonTitle:(NSString *)cancelButtonTitle
                                             otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
 

+ 4 - 4
UIKit+AFNetworking/UIAlertView+AFNetworking.m

@@ -43,13 +43,13 @@ static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __
 @implementation UIAlertView (AFNetworking)
 
 + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
-                                         delegate:(id /*<UIAlertViewDelegate>*/)delegate
+                                         delegate:(id)delegate
 {
     [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil];
 }
 
 + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task
-                                         delegate:(id /*<UIAlertViewDelegate>*/)delegate
+                                         delegate:(id)delegate
                                 cancelButtonTitle:(NSString *)cancelButtonTitle
                                 otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION
 {
@@ -70,13 +70,13 @@ static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __
 #pragma mark -
 
 + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
-                                                     delegate:(id /*<UIAlertViewDelegate>*/)delegate
+                                                     delegate:(id)delegate
 {
     [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlert View Cancel Button Title") otherButtonTitles:nil, nil];
 }
 
 + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation
-                                                     delegate:(id /*<UIAlertViewDelegate>*/)delegate
+                                                     delegate:(id)delegate
                                             cancelButtonTitle:(NSString *)cancelButtonTitle
                                             otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION
 {

+ 2 - 1
UIKit+AFNetworking/UIButton+AFNetworking.m

@@ -105,7 +105,8 @@
                      success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success
                      failure:(void (^)(NSError *error))failure
 {
-    void (*objc_msgSend_typed)(id, SEL, UIImage *, UIControlState) = (void *)objc_msgSend;
+
+    void (*objc_msgSend_typed)(id, SEL, UIImage *, UIControlState) = (void (*)(id, SEL, UIImage *, UIControlState))objc_msgSend;
     objc_msgSend_typed(self, selector, placeholderImage, state);
 
     NSURLSessionTask *task = [[[self class] af_sharedHTTPClient] dataTaskWithRequest:urlRequest completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {

+ 3 - 0
UIKit+AFNetworking/UIImageView+AFNetworking.m

@@ -93,7 +93,10 @@ static char kAFResponseSerializerKey;
         _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer];
     });
 
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu"
     return objc_getAssociatedObject(self, &kAFResponseSerializerKey) ?: _af_defaultImageResponseSerializer;
+#pragma clang diagnostic pop
 }
 
 - (void)setImageResponseSerializer:(id <AFURLResponseSerialization>)serializer {

+ 6 - 6
UIKit+AFNetworking/UIProgressView+AFNetworking.m

@@ -73,8 +73,8 @@ static char kAFDownloadProgressAnimated;
 - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task
                                    animated:(BOOL)animated
 {
-    [task addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskCountOfBytesSentContext];
-    [task addObserver:self forKeyPath:@"countOfBytesSent" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskCountOfBytesSentContext];
+    [task addObserver:self forKeyPath:@"state" options:0 context:AFTaskCountOfBytesSentContext];
+    [task addObserver:self forKeyPath:@"countOfBytesSent" options:0 context:AFTaskCountOfBytesSentContext];
 
     [self af_setUploadProgressAnimated:animated];
 }
@@ -82,8 +82,8 @@ static char kAFDownloadProgressAnimated;
 - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task
                                      animated:(BOOL)animated
 {
-    [task addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskCountOfBytesReceivedContext];
-    [task addObserver:self forKeyPath:@"countOfBytesReceived" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:AFTaskCountOfBytesReceivedContext];
+    [task addObserver:self forKeyPath:@"state" options:0 context:AFTaskCountOfBytesReceivedContext];
+    [task addObserver:self forKeyPath:@"countOfBytesReceived" options:0 context:AFTaskCountOfBytesReceivedContext];
 
     [self af_setDownloadProgressAnimated:animated];
 }
@@ -147,7 +147,7 @@ static char kAFDownloadProgressAnimated;
                 });
             }
         } else if ([keyPath isEqualToString:@"state"]) {
-            if ([object state] == NSURLSessionTaskStateCompleted) {
+            if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) {
                 @try {
                     [object removeObserver:self forKeyPath:@"state"];
 
@@ -159,7 +159,7 @@ static char kAFDownloadProgressAnimated;
                         [object removeObserver:self forKeyPath:@"countOfBytesReceived"];
                     }
                 }
-                @catch (NSException *exception) {}
+                @catch (NSException * __unused exception) {}
             }
         }
     }