search

Home  >  Q&A  >  body text

Objective-c - Real device test NSProgress does not print progress

progress:^(NSProgress * _Nonnull uploadProgress) {
NSLog(@"Progress - %f", uploadProgress.fractionCompleted);
}

During the real machine test, this log cannot be printed, but it works fine on the simulator. The break point in this block will not stop. Why?

黄舟黄舟2845 days ago655

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-02 09:30:09

    A common reason for this situation is redefining NSLog.
    Please check if there is code similar to the one below in your project.

    #ifdef DEBUG
    #define NSLog(format, ...) do {                                                                          \
    fprintf(stderr, "<%s : %d> %s\n",                                           \
    [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],  \
    __LINE__, __func__);                                                        \
    (NSLog)( (format), ## __VA_ARGS__ );                                           \
    fprintf(stderr, "-------\n");                                               \
    } while (0)
    #else
    #   define NSLog(...)
    #endif
    

    reply
    0
  • Cancelreply