Given a textview “editionTextView” where some text has been pasted (various sources: Excel, Numbers, pdf) I try to get each line of the text like this:
My array regularly returns empty. If the text is entered by keyboard, no problem. When the text is pasted, it’s wrong. However, the text appears normally paragraphed. I tried \r as separator without success.
To get rid of RTF and other surprises, I use a non-rich text for the text view. The problem is: what is the last character of the line? How could I “normalize” my text to get a correctly filled array?
The compiler complains that my newRecord variable is not used. And then in [aClass addObject:newRecord]; it tells me the same variable is not declared.
it must be a syntax error, or is it forbidden to create a variable into an IF test? Seems stupid.
Thank you leonsimard. Meanwhile, I’ve extracted not only the declaration of the IF test, but also the initialization of the dictionary. Then I add the keys/values into the test.
After thinking about it, I realized this is one drawback of C language. You can declare variables anywhere in code, but they have to stay in the scope. Inside an IF test, the compiler cannot decide if the variable has been declared or not. I thought: “You have to, moron, because this is an IF/ELSE statement! One of them is necessarily executed!” But. no.
Well, that’s one problem I have, accustomed to languages with a declaration part.