mutualmobile / MMProgressHUD

An easy-to-use HUD interface with personality.
MIT License
705 stars 131 forks source link

出现重定义是怎么回事? #34

Closed urmyfaith closed 9 years ago

urmyfaith commented 9 years ago

出现重定义是怎么回事?

但是在工程中总共只有四处用到这个变量


第一处:
/XXX/MMProgressHUD/MMProgressHUD+Class.m:329:                         afterDelay:MMProgressHUDStandardDismissDelay];
第二处:

/XXX//MMProgressHUD/MMProgressHUD+Class.m:367:                           afterDelay:MMProgressHUDStandardDismissDelay];

第三处:

/XXXX/MMProgressHUD/MMProgressHUD.h:31:extern float const MMProgressHUDStandardDismissDelay;

第四处:

/XXXX/MMProgressHUD/MMProgressHUD.m:34:CGFloat const MMProgressHUDStandardDismissDelay = 0.75f;

报错:

/XXX/MMProgressHUD/MMProgressHUD.m:35:15: Redefinition of 'MMProgressHUDStandardDismissDelay' with a different type: 'const CGFloat' (aka 'const double') vs 'const float'
larsacus commented 9 years ago

I cannot read Chinese, however, it appears you have having an issue compiling where the compiler tells you that you have multiple defined symbols of the same type?

Make sure you are using the latest version, as currently MMProgressHUD.m:34 does not contain what you described above.

It looks like, depending on your compiler flags, you could have an issue compiling with the error you described due to a type error in the method declaration in MMProgressHUDPrivate.h:104:

MMProgressHUDPrivate.h:104:

- (void)dismissWithCompletionState:(MMProgressHUDCompletionState)completionState
                             title:(NSString *)title
                            status:(NSString *)status
                        afterDelay:(float)delay;

change to:

- (void)dismissWithCompletionState:(MMProgressHUDCompletionState)completionState
                             title:(NSString *)title
                            status:(NSString *)status
                        afterDelay:(CGFloat)delay;

Let me know if this helps.

larsacus commented 9 years ago

I just pushed up commit 32bdc42 that has this change.

urmyfaith commented 9 years ago

I am very sorry to use Chinese to post this issue.

At the same time, I am very glad that you have graped what I am taking about.


Come to this issue, I have found that's a problem about 32 bit simulator or 64 bit simulator,

when the project's target is iPhone Retina(3.5-inch) or iPhone Retina(4-inch), there is no problem when compiling.

But,when choosing iPhone Retina(4-inch-64bit)(under Xcode 5.1.1) or iPhone 6(under Xcode 6+),

the compiler will rase this redefine error.

problem1

I just downlaod your git project and poll your "Source" directory into my project.

where are your MMProgressHUDPrivate.h:104: file? I could not find that file in this repository.

problem2

Instead of using the the code blow:

- (void)dismissWithCompletionState:(MMProgressHUDCompletionState)completionState
                             title:(NSString *)title
                            status:(NSString *)status
                        afterDelay:(float)delay;

here is what my code is:

            [MMProgressHUD setPresentationStyle:MMProgressHUDPresentationStyleFade]; 
            [MMProgressHUD showProgressWithStyle:MMProgressHUDProgressStyleIndeterminate                                           title:nil
                                          status:@"loading"];
        [manager GET:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
            [self analyJSON:responseObject];
            [MMProgressHUD dismissWithSuccess:@"load complet"];
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            [MMProgressHUD dismissWithError:nil title:@"load failed."];
        }];

Thanks for your reply.

Sorry for using Chinese again.

larsacus commented 9 years ago

I tried reproducing what you've given me and I'm having a hard time getting the compiler to give me the same error you have shown above. In fact, the constant at MMProgressHUD.m:35 that the error is supposed to be pointing to is not on line 35, but on line 37, which tells me you are using an oudated commit of the codebase.

Secondly, the enum MMProgressHUDProgressStyle and the corresponding API methods that accept that enum have been deprecated in the latest version of the code.