iphone Simulator crash? - iphone

I'm develop app for iPhone & iPod and during developing app i used simulator 3.2(iPad) it runs perfectly but when I want to my app on simulator 3.1.3 it generate one error I remove this error by comment this line //self.clearsSelectionOnViewWillAppear = NO;
and build project successfully but run app on simulator 3.1.3 when i clicking on button it goes on another screen on 3.2 simulator perfectly & crash on 3.1.3
what i do for come out from it.

The docs for UITableViewController clearly state that clearsSelectionOnViewWillAppear is available on iOS 3.2 and above. It crashes in 3.1.3 because this property does not exist in 3.1.3 (you can easily surmise this from reading the documentation for the property that you have already discovered is causing the issue, or from looking at the error message which will indicate that the object does not respond to a selector for setClearsSelectionOnViewWillAppear.
Before setting this, you can check for this property and then set it, otherwise your older code can just be supported as is, or you could do something more advanced and add the property in pre-3.2 environments.
To check for the code, you do something like this:
if( [UITableViewController instancesRespondToSelector:#selector(setClearsSelectionOnViewWillAppear:)] ) {
// This is 3.2+ so we can use this property
[self setClearsSelectionOnViewWillAppear:NO];
} else {
// This is something earlier than 3.2, so we ignore it
NSLog(#"will clear selection: pre-3.2");
}

Can you explain your question more clearly?
My dear friend,
You should read the Apple documentation more attentively,
It is clearly stated that
clearsSelectionOnViewWillAppear
is a method available from iPhone OS 3.2 and later,you are trying to use it in 3.1.3.
So the result is obvious.
clearsSelectionOnViewWillAppear
A Boolean value indicating if the controller clears the selection when the table appears.
#property(nonatomic) BOOL clearsSelectionOnViewWillAppear
Discussion
The default value of this property is YES. When YES, the table view controller clears the table’s current selection when it receives a viewWillAppear: message. Setting this property to NO preserves the selection.
Availability
Available in iPhone OS 3.2 and later.
Declared In
UITableViewController.h
Thanks

Related

Detect iOS Simulator vs. iOS Device

I am working on a project using Xamarin.iOS and I have a situation where a behavior in the simulator inexplicably is not the same on an actual device (setting the region of a mapview centers differently).
I want to be able to set a value for a variable at runtime based on whether the app is running on the simulator or a real device. How can I detect this?
You can execute different code at runtime like this:
if (ObjCRuntime.Runtime.Arch == Arch.DEVICE) {
} else {
}
But it's always good to investigate (ask around here, forums, bug reports) why the behaviour differs between the two (just to make sure it does not hide a bug that could bite you later).

ADBannerContentSizePortrait not available on iOS 5

I am adding the iAd framework to an existing application. The application is portrait only and iPhone only. Everything is running in iOS 6, both in the simulator and on an iPhone 5. However, it fails in iOS 5 both in the simulator and on an iPhone 4. It throws the following exception:
'NSInternalInconsistencyException', reason: 'currentContentSize must be one of the requiredContentSizes; 'ADBannerContentSizePortrait' is not in {(
ADBannerContentSizeLandscape
)}'
The exception is thrown on this line:
iAdBannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
I see no way of displaying anything other than a landscape banner this way. I'm assuming I must have something configured wrong somewhere, but I don't know where, and find it curious that it works fine in iOS 6.
Any help here is greatly appreciated! Thanks!
UPDATE: I can't answer this because I don't have enough rep points. But I have it fixed:
Background: I'm using the Kobold2D wrapper around ADBannerView. It's class, KKAdBanner, is the one that is actually calling the line causing the error. It turns out, it was preceding this call by configuring ADBannerView to only allow landscape sizes. This was a configuration issue and I can resolve it.
Of course, now I don't know why in the world it ever worked in iOS 6 at all, but oh well :-)
I've never used this, but from what I'm understanding from the documentation you need to set the #property(nonatomic, copy) NSSet *requiredContentSizeIdentifiers
with all the value that currentContentSizeIdentifier could take.
And your exception is saying that in that NSSet you only have the one for the landscape.
The difference you are seeing could be due to a different default values in different iOS version. (I'm guessing)
Reference here.

App Created with ios4 is crashing in ios6 and not installing

My App, which is created for iOS4, is crashing in iOS6 and is not installing on simulator or device.
It just shows the splash screen and crashes.
Did finish Launching is not being called.
Can anybody please Help?
Finally i got the solution of my problem mentioned above.
In my ios4 App, in FirstViewController.xib "Use AutoLayout" was checked.
I just removed the checkmark and my App start working.
Amazing!!!
I would recommend creating a new project, and either carefully looking for the changes in delegate or any deprecated code, or just moving all of your code to the new project. Also, you should run a convert to modern syntax check.
There may be issue with Application Delegate. The obvious reason - your object is not set as an application delegate.
Looking at Apple documentation there is quite a few ways to accomplish it:
Remove application delegate binding in Interface Builder (.xib file
for the window) Set 4th parameter of UIApplicationMain in main.h to
something else than nil.
Check you nib file in Interface Builder and see if the App Delegate is setup.
Or Reference to documentation Core Application Design
Hope this will you out.
Look into the release notes of xcode, ios6
It is said that when working with IOS6, Auto Layout is turned on and that crashes the app if used on older versions. Check the link, which has other things to watch out for:
https://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-Xcode/_index.html
https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html

NSMutableAttributedString on iOS 3.1.3

I'm dealing with a very odd situation. I'm implementing Attributed Strings into my iOS application, and I had the warning going in that they are available iOS 3.2 and above. Because I still support 3.1.3 on iPhones, I knew I had to weakly link CoreText and probably so some compile time OS check before using them.
I weakly linked the framework, but out of curiosity I just used the class as is and ran it on a 3.1.3 device... and it works. What am I missing here, I'm so confused why this isn't crashing. I'm 100% sure this is a 3.1.3 device, but is NSMutableAttributedString a hidden class on 3.1.3, and thus actually does work because of the dynamic nature of objective-c ?
I am the author of the OHAttributedLabel class.
Thanks for using it!
The behavior you have is strange, as OHAttributedLabel uses the CoreText framework to draw the NSAttributedStrings on screen.
As CoreText is only available since iOS 3.2, I can't see how it would be possible for this to work under iOS 3.2, especially iOS 3.1.3…?
Did it really work, instead of just not crashing?
Depending on the setting, a non-existent class becomes just nil. Note that in Objective-C you can send a message to a nil. Then it just returns nil or 0. Then [[NSAttibutedString alloc] init] might just return nil, without crashing.
CoreText was introduced with iOS 3.2. If you weak link against it the app will start, but it will crash on the first instance on calling a CoreText function.
To still be compatible with earlier versions you CAN weak link and avoid CT code by drawing the text with Quartz instead. You would detect if CT exists on the device and use it if yes, otherwise you would have a crude fallback mechanism for your drawing.

Universal iPhone/iPad application debug compilation error for iPhone testing

I have written an iPhone and iPad universal app which runs fine in the iPad simulator on Xcode, but I would now like to test the iPhone functionality. I seem unable to run the iPhone simulator with this code as it always defaults to the iPad?
Instead I tried to run on the device and as it begins to run I get the following error:
dyld: Symbol not found: _OBJC_CLASS_$_UISplitViewController
Referenced from: /var/mobile/Applications/9770ACFA-0B88-41D4-AF56-77B66B324640/Test.app/Test
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit in /var/mobile/Applications/9770ACFA-0B88-41D4-AF56-77B66B324640/Test.app/TEST
As the App is built programmatically rather than using XIB's, I've split the 2 device logics using the following lines in the main.m method:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate_Pad");
}
else
{
retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate_Phone");
}
From that point forth they use different AppDelegates and I've checked my headers to ensure the UISplitView is never used nor imported via the Phone logic.
How do I avoid this error and is there a better way to split the universal logic paths in this programmatically-created app?
That error is being triggered because you didn't weak-link the UIKit framework. The UIKit framework in iPhone OS 3.2 added the UISplitViewController, and if you link it in as normal your application will assume those symbols exist on 3.0, where they don't.
To weak-link a framework, find your application target in Xcode, inspect it, and go to the General tab. At the bottom of that tab should be a list of frameworks, with a column for Type. Change the Type for UIKit from Required to Weak and rebuild your application. That should take care of the runtime errors.
Your conditional logic is sound, but I tend to share an application delegate and do the interface-specific layout further down the line.
(Update: 12/21/2011) As of iOS 4.2, you should no longer need to weak link frameworks to prevent errors like this. As Marco Arment describes, if you build with iOS 4.2 or later and target down to iPhone OS 3.1+, individual classes are now weak linked and should have their +class method return nil if the class does not exist on the currently running version of the OS.
I was having a very similar error and it was driving me nuts! :-) Searching for hours and couldn't figure it out...
Like you said, everything was fine when running in the iPad Simulator but when trying to test the App on the iPhone with iPhone OS 3.1.2 it would not even start but crash with the following error message:
mi_cmd_stack_list_frames not enough frames in stack
By checking nearly every line of code I realised that the allocating of 3.2 classes like UIPopoverController or UISplitViewController (already inside forked iPad-specific code) was causing the problem.
So instead of i.e.:
infoPopover = [[UIPopoverController alloc] initWithContentViewController: infoNavController];
i would write
infoPopover = [[NSClassFromString(#"UIPopoverController") alloc] initWithContentViewController: infoNavController];
and that solved my problem! (Debugging can be so hard if the error message gives you no clue about where the bug could possibly be found...)
Xcode 8.3, iPad 2 (non retina), Swift 3 code
What helped for me was:
restart Xcode
do a 'Product -> Clean' ShiftCommandK
rebuild the project