Giter Site home page Giter Site logo

Comments (16)

JaxMyers avatar JaxMyers commented on June 2, 2024

I am getting the same issue. Had you figured this one out yourself by any chance?

from chcsvparser.

yoasha avatar yoasha commented on June 2, 2024

I didn't really try to handle these warnings as they are harmless. I am also sure that this issue will be targeted by the project owner when he will get to it.

from chcsvparser.

thomasaw avatar thomasaw commented on June 2, 2024

I just checked and this warning doesn't occur with the HEAD version of CHCSVParser.

from chcsvparser.

jeffdgr8 avatar jeffdgr8 commented on June 2, 2024

Definitely still getting these warnings with the latest code on the master branch today. They are the only warnings in my project. It would be very nice to have them fixed.

from chcsvparser.

thomasaw avatar thomasaw commented on June 2, 2024

You're right. This is occurring with Xcode 7. A related warning with Xcode 6.4 was fixed by moving to HEAD.

from chcsvparser.

bakwarte avatar bakwarte commented on June 2, 2024

This SO link seems to explain what's causing the warning (http://stackoverflow.com/a/24565513/45813). If you are very concerned about removing the warnings your best option now is to suppress them:
In your project:

  1. Edit the build settings for your the CHCSVParser target.
  2. Search for "Other warning flags".
  3. Add -Wno-objc-designated-initializers

You could do turn it off on a per file basis as well as the link explains

from chcsvparser.

JaxMyers avatar JaxMyers commented on June 2, 2024

You can disable the warnings by a adding this at the top of your CHCSV.m and CHCSV.h files just before @interface.

#ifdef __IPHONE_8_0
// suppress these errors until we are ready to handle them
//#pragma message "Ignoring designated initializer warnings"
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
#else
// temporarily define an empty NS_DESIGNATED_INITIALIZER so we can use now,
// will be ready for iOS8 SDK
#define NS_DESIGNATED_INITIALIZER
#endif

from chcsvparser.

thomasaw avatar thomasaw commented on June 2, 2024

Dave has recently checked in changes to a 3.0.0 branch of this project. The 3.0.0 version is Swift-based and doesn't have this warning.

from chcsvparser.

mgil-xx avatar mgil-xx commented on June 2, 2024

I'm having this same issue on Xcode 7.2 . I'm on the latest objective c Branch.
Is there a way to solve this, other then suppress the warning?
thanks

from chcsvparser.

yoasha avatar yoasha commented on June 2, 2024

This warning appears since the designated initializer of the super class (NSObject > init) is not implemented in CHCSVParser and CHCSVWriter classes. The reason it's not implemented is that the library creator wished us the developers to use only the designated and convenience initializers defined in these classes.

In my own code I use the following approach in similar cases:

  1. In the h file, I am adding the following declaration:
  • (instancetype)init NS_UNAVAILABLE;
  1. In the m file, I am adding the following implementation:

  2. (instancetype)init {

    [NSException raise:NSInternalInconsistencyException format:@"Illegal call to designated initializer of super class (%@). Please call only initializers defined in this class!", NSStringFromSelector(_cmd)];

    return nil;
    }

This way, warnings are gone, calling to the init initializer will generate a compile time error, and getting somehow to the init initializer method bypassing the compiler error (maybe by dynamic dispatch) will generate a runtime exception.

Any thoughts?

from chcsvparser.

mgil-xx avatar mgil-xx commented on June 2, 2024

Hi yoasha,
I tried your implementation without success. a new warning says "Convenience initializer missing a 'self' call to another initializer"
thanks for helping

from chcsvparser.

yoasha avatar yoasha commented on June 2, 2024

It doesn't make a lot of sense... please try the following just to see what is wrong:

In the CHCSVParser.h remove the following code that I previously asked to add:
- (instancetype)init NS_UNAVAILABLE; from the h file and add

In the CHCSVParser.m, replace the code that I previously suggested with the following one:

 - (instancetype)init {
    return [self initWithCSVString:nil];
}

Let me know if there are any warnings for the CHCSVParser class

from chcsvparser.

mgil-xx avatar mgil-xx commented on June 2, 2024

Hi yoasha,
this solves one warning (@implementationCHCSVParser)`

using the same idea I added
- (instancetype)init { return [self initForWritingToCSVFile:nil]; }
to solve the second warning @implemantation CHCSVWriter
this way, the warnings are gone.

I like your idea to add some alert to avoid the programmer trying to initialize using init. Maybe returning nil. Xcode asks to call self anyway, so I ended with this.

`-(instancetype)init {

self = [self initForWritingToCSVFile:nil];

[NSException raise:NSInternalInconsistencyException format:@"Illegal call to designated initializer of super class (%@). Please call only initializers defined in this class!", NSStringFromSelector(_cmd)];

return nil;

}
`
thanks for helping

from chcsvparser.

yoasha avatar yoasha commented on June 2, 2024

Very interesting. In my code, I don't need to add the following line (just before the exception code) in order to prevent the warning:
[self initForWritingToCSVFile:nil];

Having just the NSException code did the work for me. I am not sure why, but maybe it's related to the warning level preferences in Xcode which might be different in our dev environments.

BTW, after adding your code to the implementation file that prevented the warnings, did you try to add again the following line to the h file?
- (instancetype)init NS_UNAVAILABLE;

This line should be very useful as it prevents calling this initializer at compile time rather than runtime.

from chcsvparser.

mgil-xx avatar mgil-xx commented on June 2, 2024

Hi yoasha,

good news! I didn't try before to just add - (instancetype)init NS_UNAVAILABLE; into the h file. The good news is that it solves the warnings and avoid the use of init .

I asked this same question on stackoverflow http://stackoverflow.com/questions/38044609/chcsvparser-warnings-how-to-solve-this-one, without answer. Would you like to answer this question with the help you give me? My english is really poor, and you guide me find the right solution. I really thank you for helping so much.

from chcsvparser.

yoasha avatar yoasha commented on June 2, 2024

Hi, I'm glad this helped.

@davedelong (or any user with admin rights), what do you think about this solution? I can submit a pull request if you find this solution legit.

from chcsvparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.