Constraint constant is nil iOS 7 but not in iOS 8 - ios7

I have 3 outlets that change constant variables in 3 views, and can't seem to understand why this happens. NOTE: THIS HAS NOTHING TO WITH THE INTERFACE (so no setneedlayout or layoutifneeded answers). I get it.
// iOS 7
_fillerConstraint.constant = 200;
NSLog(#"_fillerConstraint: %f", _fillerConstraint.constant);
2015-02-15 08:55:14.54 Hurricane[44367:613] _fillerConstraint: 0.000000
// iOS 8
_fillerConstraint.constant = 200;
NSLog(#"_fillerConstraint: %f", _fillerConstraint.constant);
2015-02-15 08:55:14.547 Hurricane[44367:613] _fillerConstraint: 200.000000
A method is called from viewwillappear to set these values and do some animation. All is well in iOS 8 and works as expected. However in iOS7 the debugger is reporting the constraint is nil. Anyone know what might cause this behavior?

After cleaning the app and resetting the simulators. It works fine. The answer to issues like this is, Xcode 6 is full of bugs.

It might sound dumb, but for future dummies my problem was that the constraint was with a view that is no longer in the view hierarchy(I removed it) so obviously the constraint was nil.

Related

Something very strange UITextView in iOS 7 ... not in iOS 6?

I'm creating a UITextView:
greetingTextView = [[UITextView alloc] initWithFrame:greetingRect];
Using it fine, but when the ViewController it is attached to deallocs I'm getting memory leaks ONLY in iOS 7 ? I'm even Nulling the greetingTextView out of desperation but to no effect:
[greetingTextView.undoManager removeAllActions];
greetingTextView.delegate = Nil;
[greetingTextView removeFromSuperview];
greetingTextView = Nil;
The leaks are in this image:
So it appears something to do with the UITextView UndoManager ? But why only in iOS 7 ?
Regards
I face a similar situation, and after hunting around and some trail and error, i noticed that when ARC is disabled for that particular file, the strange behavior stopped and no memory leaks occurred. check here for how to disable arc for a particular file
You'll need to empty out the undo manager if you want any object you add to it to be released.
Review the steps laid out in this document :
https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/UndoArchitecture/Articles/CleaningUndoStack.html
It did occurs to me once when I didn't specify the delegate of a UITextField. After the delegate was set everything went normal. Hope it helps. BTW, I'm using Storyboard.

iOS application slows down on real device

I have iOS 6 application that consists of UIView with many UIButtons (like 9 to as many as 100) displayed at same time; all buttons are movable, so I'm changing button's frame property all the time.
After using the application for a couple of minutes (= moving buttons around the parent UIView), app slows down. It is very strange also that it seems buttons that are near the bottom of the screen (= parent UIView) are much slower than those on the top of screen.
All buttons belong to same class, inherited from generic UIButton.
It happens only on real device, not iPhone simulator.
Any idea about the issue? I'm using NSlog frequently through the code. Can this be the problem?
Thx,
DJ
You can set your NSLogs to be only in DEBUG mode, it will be much faster in Relese:
#ifdef DEBUG
NSLog(#"log");
#endif
Yes you are right.
Never give NSLog or DLog in release versions..
remove all nslog, or for testing purpose just comment them out.
#ifdef DEBUG
NSLog(#"log");
#endif
or
#define NSLog //NSLog
Also you should check for zombies and memory leaks.

How to use NSLayoutConstraint in iOS 6?

My app should support both iPhone resolutions (5 and older) using iOS 5 and iOS 6. When I use autolayouts in IB, on iOS 5 app crashes like this: link
So, I am trying to use NSLayoutConstraint in code, but unsuccessfully yet.
Subquestions:
I am adding constraints in viewDidLoad method, but is it correct?
Does updateViewConstraints invoke by framework? I have never seen that it was invoked.
I tried to use examples from apple's docs, but it was without effect to view.
Anybody knows how to do it?
PS: I know it's possible to make it manually by setting frames, but I would like to use NSLayoutConstraints.
UDP: Yes, I know, that's why i use NSLayoutConstraint in code. I can make condition for determining iOS version. The question is about iOS6.
The AutoLayout feature is only compatible with iOS6 and is not supported in iOS5. Thus the crash
If you intend your app to be compatible with iOS5, you can't use AutoLayout in your XIB files.
You can only use older methods, like the AutoResizingMask for example (which is often sufficient for most cases anyway).

-[UITableView setStyle:] in iOS 6 crashing the app (but not in iOS 5.1)

For some reasons we have situations when we have to set properties from a NSDictionary to an UIView.
Everything was OK 'till the iOS 6 was released. Now -[UITableView setValue:value forKey:#"style"] is crashing the app. In iOS 6 it calls setValue:forUndefinedKey: but in iOS 5.1 it doesn't (and everything is OK then). I know that style UITableView's property is read-only but... why? I have my own implementation of setValue:forUndefinedKey: but I don't want to filter somehow such properties (it'll be difficult to).
I know that style UITableView's property is read-only but... why?
Because Apple decided to be so, and they probably have a pretty good reason for it. Don't try setting readonly properties, they will crash your app.

EAAcessory errors while closing session with iOS 6.0 GM

There is a MFI device that is connected to iPhone 4S (6.0 GM) or to iPad (6.0 GM) via Bluetooth (2.1 + EDR). The project was built on Xcode 4.5 GM. When the app gets EAAccessoryDidDisconnectNotification it will send message [_eaSessionController closeSession];. All these worked nice in iOS 5.1.1 or earler. But on iOS6 with this message I got logs as follows:
-[NSCondition dealloc]: condition (<NSCondition: 0x2e5640> '(null)') deallocated while still in use
Break on _NSLockError() to debug.
Any ideas?
I came across the same issue. This warning is thrown when calling [NSStream close] upon receiving an EAAccessoryDidDisconnectNotification. There should be also some data exchange between the two devices just before the disconnection.
Breaking on _NSLockError will show that at the moment the object is deallocated, some of the threads spawned by the external accessory framework are waiting on conditions. One of those certainly waits on the condition that is being freed, which explains the warning thrown on the console.
I also noticed that the number of threads created by the external accessory framework keeps on growing each time the accessory disconnects then connects, and they seem to be just leaking.
It seems to me that somehow, the external accessory framework does not properly free the resources it allocates, which results in a lot of mess. One of the subsequent effects of this are crashes that happen inside one of those leaked threads during a call to OSAtomicCompareAndSwap64.
I managed to reproduce the issue using a basic sample in which the streams are scheduled on the main thread to avoid any thread management inside the application. I believe it's an accessory management bug on iOS 6 that Apple should be aware of. I'll report it and wait for what they have to say.
Meanwhile, I wonder if anyone of you guys has managed to make any progress on this.
Thanks,
There is no such trouble in iOS 6.1+. To fix this for iOS 6.0 and iOS 6.0.1 please use next solution:
Please note: this is only temp solution allow your users with iOS 6.0 and 6.0.1 continue use your app.
There is a simple hack to avoid application crashes: just create new category and override dealloc method (NSCondition) for iOS 6.0 and iOS 6.0.1:
#import "NSCondition+LeakDealloc.h"
#import <objc/runtime.h>
#implementation NSCondition (LeakDealloc)
- (void) safeDealloc
{
float sVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (sVersion < 6.0 || sVersion >= 6.1)
{
[self safeDealloc];
}
}
+ (void) load
{
method_exchangeImplementations(class_getInstanceMethod(self, #selector(dealloc)), class_getInstanceMethod(self, #selector(safeDealloc)));
}
#end
This solution make new leak, after 20 min tests and about 50 BG/FG swithces instruments shows 10 NSCondition leaks (960 Bytes), BUT no one crash!
The issue has been fixed in iOS 6.1.
There are no more leaking NSCondition or external accessory threads. Apple seem to having fixed the issue properly.