UIProgressView scaling inconsistency issue [duplicate] - ios

This question already has answers here:
Dot Notation vs Method Notation
(6 answers)
Closed 8 years ago.
Total newb here.
What is the difference between this
_myUIProgressView.transform = CGAffineTransformScale(_myUIProgressView.transform, 1.0, 0.3);
and this:
[_myUIProgressView setTransform:CGAffineTransformMakeScale(1.0, 0.3)];
besides the brevity. Why would you favor one over the other?

Those 2 calls are functionally identical. The only difference is syntax.
The first is called dot notation. The second is a method call to the setter.
Dot notation is an alternative way to invoke a property's setter or getter, and it does exactly the same thing as the other syntax.
Some people (mostly old school C programmers) don't like the dot syntax. I'm an old C programmer, but I like it.

Related

replace text in TeX [duplicate]

This question already has answers here:
Is there any way I can define a variable in LaTeX?
(5 answers)
Closed 5 years ago.
Is there a way to add a text by reference using LaTeX? I have several text references to 'versionXX.yy'. I wonder if I can define this in one place so I don't need to update it in all places.
Thanks
You could define a variable or new command with your version at the beginning and then just use this definition. See here
Btw. there is a special site called tex.stackexchange.com for this kind of questions.

'++' is deprecated: it will be removed in Swift 3 [duplicate]

This question already has answers here:
The "++" and "--" operators have been deprecated Xcode 7.3
(12 answers)
Closed 6 years ago.
After update to Xcode 7.3, there are bunch of warnings showing in my project.
'++' is deprecated: it will be removed in Swift 3
Any idea to fix this warning ? Any reasons why the ++ and -- will be deprecated in the future ?
Since Swift 2.2, you should use += 1 or -= 1 instead.
And after looking up Swift's evolution, there are some reasons for removing these operators:
These operators increase the burden to learn Swift as a first programming language - or any other case where you don't already know these operators from a different language.
Their expressive advantage is minimal - x++ is not much shorter than x += 1.
Swift already deviates from C in that the =, += and other assignment-like operations returns Void (for a number of reasons). These operators are inconsistent with that model.
Swift has powerful features that eliminate many of the common reasons you'd use ++i in a C-style for loop in other languages, so these are relatively infrequently used in well-written Swift code. These features include the for-in loop, ranges, enumerate, map, etc.
Code that actually uses the result value of these operators is often confusing and subtle to a reader/maintainer of code. They encourage "overly tricky" code which may be cute, but difficult to understand.
While Swift has well defined order of evaluation, any code that depended on it (like foo(++a, a++)) would be undesirable even if it was well-defined.
These operators are applicable to relatively few types: integer and floating point scalars, and iterator-like concepts. They do not apply to complex numbers, matrices, etc.
Finally, these fail the metric of "if we didn't already have these, would we add them to Swift 3?"
Please check out Swift evolution for more info.

float unusual behaviour Objective c [duplicate]

This question already has answers here:
Trouble with floats in Objective-C
(3 answers)
Closed 7 years ago.
I am getting an unusal issue with float in Objective C. I enter 100.1 and i get 100.100002 shouldn't it be something like 100.100000 .
Following is the code
float temp=100.1;
NSLog(#"%f",temp);
100.100000
Can someone guide me what am i doing wrong or how to fix it ? I cannot use fixed decimal places i-e i cannot just use 100.10 . I need all decimal places .
Because that is a fundamental part of what happens when you represent an arbitrary floating point value in binary. The number of binary digits is limited, therefore rounding occurs. Depending on your needs, you might be better off using NSDecimalNumber.
Try using double instead;
double temp=100.1;
NSLog(#"%.8f",temp);
100.10000000
It is an issue with representation accuracy. I do not think it will be a problem to use double instead.

What is self->property? [duplicate]

This question already has answers here:
What is the difference between '->' (arrow operator) and '.' (dot operator) in Objective-C?
(3 answers)
Closed 8 years ago.
I am familiar in iOS/Objective C. Now I see people using self->property in some cases. How does it differ from self.property? What is the actual need? I googled, no answer. Curious in it.
self->property is the same as _property, meaning it accesses the ivar directly.
self.property on the other hand calls the setter/getter.

Class method access by dot operator [duplicate]

This question already has answers here:
Objective-C dot notation with class methods?
(3 answers)
Closed 9 years ago.
This question related to knowing something we don't know. I'm researching with "Why people don't use this"? Is any reason behind this related to specific tech? So read it carefully and give downvote or give correct answer.
We can write
NSMutableString *string = NSMutableString.string;
instead of
NSMutableString *string = [NSMutableString string];
Same as how can we write this method,
NSMutableString *string = [NSMutableString stringWithString:#"test"];
Update:
This question is not an duplicate which is little bit different. And I accept with below answers which is not recommended for good programmers. But They didn't explain Why, for What reason, programmers should avoid this? Could anyone give clear explanation about this with proper link or document?
NSMutableString.string is a hack. It "works" for the same reason that myString.length and [myString length] produce the same result. However, since dot notation is not used with an actual property, it is an abuse of the language feature, because properties have a different semantic. For example, when you access a property multiple times, you naturally expect to get the same result, unless the state of the object has changed in between the two invocations. Since NSMutableString.string produces a new string object on each invocation, it breaks the semantic expected of the "proper" properties, bringing down the readability of your program.
Objective-C does not have a general way of calling a method with arguments using the dot notation. There feature is very specific to properties. Although theoretically you could use MyClass.xyz = abc in place of [MyClass setXyz:abc], but that would be a hack as well.
To answer your question, Objective-C does not offer a way to call [NSMutableString stringWithString:#"test"] with dot notation.
It's just a syntactic sugar. string method has no arguments so it's treated like a getter, which is not in fact. stringWithString: is method with parameter, so you can't call like that.
In general, I'd not recommend using dot syntax with methods, it's confusing.
Objective-C dot notation with class methods?
Update
I don't think there is any technical reason you should avoid it.
It's rather in means of coding style, keeping code clean and consistent.

Resources