On 64bit iOS 8.1 simulator, Why BOOL type function return a unexpected value?

Code example:
------func.h------
#import <Foundation/Foundation.h>
@interface func : NSObject
+ (id)instance;
@end
------func.m------
#import "func.h"
@implementation func
+ (id)instance
     static func *obj = nil;
     if (obj == nil) {
          obj = [func new];
     return obj;
- (BOOL)test
     return YES;
@end
I created a new class "func" in project as above shown, set the project compile scheme to "release" mode.
I found that if I call  [func test] method from another class, its return value is not "1" on iPhone6 simulator, it is a random value. Why?
PS: I can not find this problem on iPhone6 device, it seems only happen on 64 bit simulator. Why?

Your main problem as etresoft points out, is that your trying to use -test as a class method, you'll need to declare it as:
+test { ... }
for this to work. -test and +test are two different kinds of methods, -test needs a instance of 'func' to work:
func *f = [[func alloc] init]; // create instance f of func
[f test]; // calls -test, -test can use f as self
while +test needs a class (name):
[func test]; // calls +test
Class methods are mainly used for creating/initiating instances of a class, the +init method is a typical example of this, other uses are are for utility methods that may not really be tied to a specific object (class instance). Also note that a class method doesn't have access to self as it wasn't called on an object, so data will need to be passed in via parameters or by using global variables.
===============
dispatch_once() is the recommended way to do singletons, although the above will typically work assuming that its not accessed by multiple threads, e.g. is only used on the main thread.
===============
This page http://www.bignerdranch.com/blog/bools-sharp-corners/ appears to relate to etrsofts dislike for BOOL (the standard boolean type of Objective-C) and his preference for bool (the C++ variant), but as the page mentions: "Update October 2013 - On 64-bit iOS (device and simulator) BOOL is now actually bool, so the sharp corners have thankfully gone away for that platform. For everything else, though…"

Similar Messages

  • Why does getdate() function return same time value for multiple select statements executed sequentially

    When I run the following code
    set nocount on
    declare @i table(id int identity(1,1) primary key, sDate datetime)
    while((select count(*) from @i)<10000)
    begin
    insert into @i(sDate) select getdate()
    end
    select top 5 sDate, count(id) selectCalls
    from @i
    group by sDate
    order by count(id) desc
    I get the following results. 
    sDate                   selectCalls
    2014-07-30 14:50:27.510 406
    2014-07-30 14:50:27.527 274
    2014-07-30 14:50:27.540 219
    2014-07-30 14:50:27.557 195
    2014-07-30 14:50:27.573 170
    As you can see the select getdate() function returned same time up to the milisecon 406 time for the first date value.  This started happening when we moved our applications to a faster server with four processors.  Is this correct or am I
    going crazy?
    Please let me know
    Bilal

    Observe that adding 2 ms is accurate only with datetime2.  As noted above, datetime does not have ms resolution:
    set nocount on
    declare @d datetime, @i int, @d2 datetime2
    select @d = getdate(), @i = 0, @d2 = sysdatetime()
    while(@i<10)
    begin
    select @d2, @d, current_timestamp, getdate(), sysdatetime()
    select @d = dateadd(ms,2,@d), @i = @i+1, @d2=dateadd(ms,2,@d2)
    end
    2014-08-09 08:36:11.1700395 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1720395 2014-08-09 08:36:11.173 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1740395 2014-08-09 08:36:11.177 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1760395 2014-08-09 08:36:11.180 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1780395 2014-08-09 08:36:11.183 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    2014-08-09 08:36:11.1800395 2014-08-09 08:36:11.187 2014-08-09 08:36:11.170 2014-08-09 08:36:11.170 2014-08-09 08:36:11.1700395
    DATE/TIME functions:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Why Json get function returns null in jsp page??

    Hi guys,
    i have developed a simple program that send HTTPrequest and get json as response. now i want to display this json to Treeview but i have able to get the valid json, i create a json object and setData(json). still its ok. but when i do json.get("id"). i get null. it is not working for any of the key present in that json object. can some one help me?? below is the code i am using.
    where sb is StringBuffer containt json in text form
    System.out.println(sb);
    JSONObject obj = new JSONObject();
    obj.setData(sb);
    System.out.println(obj.getData());
    System.out.println(obj.get("id"));
    thanks in advance...

    What is the data?

  • My Iphone5 does not show the picture location after upgrading to ios 7.0.4 - why?

    my Iphone5 does not show the picture location after upgrading to ios 7.0.4 - why?

    I change Settings>Privacy>Location Services>Camera to OFF and then ON and the locations start to appear !!!!.
    It seems to be Apple bug.
    Thanks for you efforts

  • Hello, i'm Gabriele. One month ago, i have updated my iPhone 4 to iOS 7...why i did it??? UNUSABLE ( also with "reduce speed" in preference) but nothing...How can i donwgrade my iPhone 4 to whichever iOS 6? i can't afford to buy another iPhone...help me.

    Hello, i'm Gabriele. I'm from Italy, i'm 16 years old. One month ago, i have updated my iPhone 4 to iOS 7...why i did it??? UNUSABLE ( also with "reduce speed" in preference) but nothing...How can i donwgrade my iPhone 4 to whichever iOS 6? i can't afford to buy another iPhone...help me please...I am willing to do anything. Apple 4Ever. Peace. Steve Jobs RIP.

    Sorry downgrading isn't supported by apple.
    You can try settings - general - reset - reset network settings.
    take a look at this link http://osxdaily.com/2013/09/23/ios-7-slow-speed-it-up/

  • Error loading/installing iOS 5.0 Simulator in XCode 4.4.1

    I'm new to iOS and Apple.
    Just got XCode installed, but when I try to dowload/install iOS 5.0 Simulator using the 'Download' tab of XCode preferences, I get the following error consistently:
    Failed to mount file://localhost/Users/reza/Library/Caches/com.apple.dt.Xcode/Downloads/Xcode.S DK.iPhoneSimulator.5.0-5.0.0.1.dmg at file://localhost/var/folders/bm/kz0d00lx18ncwq3fxyf50pn00000gn/T/attached-image -122057767f890c101413b3e8c64917b42f1eb792/: not recognized
    What I'm doing wrong and how can I fix it, Please ?
    I'm using Xcode 4.4.1 on OS X 10.8.1

    KT
    Thnx for the suggestions,
    I tried all of yours (logged in as a newer user, ran disk utility and everything was ok, and I have over 300GB free space on the SDD drive) but still have exactly the same problem!
    Anyone else has any other ideas on how to solve this problem, PLEASE?

  • Html + js is ok in iOS 4.2 and 4.3 but not work in iOS 5.0.1 why?

    Hi all
      I write a simple application use html + js  to display something locally,  the files to be displayed  is in the device  ,it is ok in iOS 4.2 & 4.3 but not work correctly in iOS 5.0.1.
    why?

    If you have iPhone 3G, the latest and greatest is IOS 4.2.1.
    If you have iPhone 3GS or later, you can only update to IOS 6.0.1.
    For iPhone 5 and iPad mini, you can update to IOS 6.0.2.

  • IOS 6.0 simulator error / Flex+AIR 3.5

    I am not able to run a Flex/AIR program on the IOS 6.0 simulator. I searched all forums. I am new to using IOS simulator. Any help is appreciated.
    I am using Flex 4.6 and AIR 3.5, with target swf version 18. A simple Flex app (WindowedApplication with a Label in it) crashes at initialization in IOS simulator.
    <?xml version="1.0"?>
    <s:WindowedApplication
      xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:s="library://ns.adobe.com/flex/spark">
      <s:Label text="Test"/>
    </s:WindowedApplication>
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at spark.components::WindowedApplication/initialize()
      at ptest/initialize()
      at mx.managers.systemClasses::ChildManager/childAdded()
      at mx.managers.systemClasses::ChildManager/initializeTopLevelWindow()
      at mx.managers::SystemManager/initializeTopLevelWindow()
      at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::kickOff()  at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::preloader_completeHandler()
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.preloaders::Preloader/timerHandler()

    Update: the problem was resolved by changing WindowedApplication to Application.
    Is WindowedApplication not allowed for IOS/mobile ? I couldn't find any doc on this.

  • How to install iOS 7.0 Simulator in xcode 6.0.1

    I go to preference and download the simulator 7.0,then i got this error Could not download and install iOS 7.0 Simulator. Failed to mount file:///Users//Library/Caches/com.apple.dt.Xcode/Downloads/Xcode.SDK.iPhoneSimu lator.7.0-7.0.dmg at file:///var/folders/p0/94d17pz545l9w47byr0z2gzcr14jm4/T/attached-image-0f91fbf0 58f8f65f6ddbe8e8e28dbeaa6b366f89/: image not recognized.Kindly help me solve this issue.
    Message was edited by: sassudalai

    KT
    Thnx for the suggestions,
    I tried all of yours (logged in as a newer user, ran disk utility and everything was ok, and I have over 300GB free space on the SDD drive) but still have exactly the same problem!
    Anyone else has any other ideas on how to solve this problem, PLEASE?

  • I used iphone 3gs iOS 6.1.6 why i can't open an application camera 360 ultimate

    I used iphone 3gs iOS 6.1.6 why i can't open an application camera 360 in my iphone

    Hello Kunmon,
    The following article provides some useful troubleshooting that can help get your iPhone's camera working correctly.
    Camera isn't functioning or has undesired image quality
    If the screen shows a closed lens or black image, force quit the Camera app.
    If you do not see the Camera app on the Home screen, try searching for it in Spotlight. If the camera does not show up in the search, check to make sure that Restrictions are not turned on by tappingSettings > General > Restrictions.
    Ensure the camera lens is clean and free from any obstructions. Use a microfiber polishing cloth to clean the lens.
    Cases can interfere with the camera and the flash. Try gently cleaning the lens with a clean dry cloth or removing the case if you see image or color-quality issues with photos.
    Try turning iPhone off and then back on.
    Tap to focus the camera on the subject. The image may pulse or briefly go in and out of focus as it adjusts.
    Try to remain steady while focusing:
    Still images: Remain steady while taking the picture. If you move too far in any direction, the camera automatically refocuses to the center.
    Note: If you take a picture with iPhone turned sideways, it is automatically saved in landscape orientation.
    Video: Adjust focus before you begin recording. You can also tap to readjust focus while recording. Exiting the Camera application while recording will stop recording and will save the video to the Camera Roll.
    Note: Video-recording features are not available on original iPhone or iPhone 3G.
    If your iPhone has a front and rear camera, try switching between them to verify if the issue persists on both.
    My issue is still not resolved. What do I do next?
    Contact Apple Support.
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Cheers,
    Allen

  • My phone won't connect to Internet since I updated to iOS 7.0.4 why??

    My phone won't work since I updated to iOS 7.0.4 why??

    Why not?
    Any errors?
    MMS or iMessage?
    Do you have a data connection?

  • I want to update to ios7 on my ipod touch, but it says that it's already upated to the current ios 5.1.1, why?

    I want to update to ios7 on my ipod touch, but it says that it's already updated to  the current ios 5.1.1, why?

    You have a 3G iPod. Those can only go to iOS 5.1.1. Its hardware does not support a higher iOS version.
    The 4G only go to 6.1.5.
    Only the 5G can go to iOS 7

  • HT4623 Using a first gen iPad with iOS 5.1.1; why does it say my software is up to date when I try to update?

    Using a first gen iPad with iOS 5.1.1; why does it say my software is up to date when I try to update?

    Because the device isn't capable of running iOS 6 and newer.
    (95617)

  • Hi Apple friends, my question is regarding, the last iOS 6.1 upgrade, why it include the LTE 4G to the iPad4 and iPad Mini with Telcel in Mexcio, and Why it was not for the iPhone 5?, when Apple will enable this feature LTE 4G on the Iphone5 to Telcel?

    Hi Apple friends, my question is regarding, the last iOS 6.1 upgrade, why it include the LTE 4G to the iPad4 and iPad Mini with Telcel in Mexcio, and Why it was not for the iPhone 5?, when Apple will enable this feature LTE 4G on the Iphone5 to Telcel?

    And Apple won't tell you. All they will tell you is what countries are supported for LTE right now. You can express your interest to Apple via their feedback pages, if you wish:
    http://www.apple.com/feedback/iphone.html
    but you will not receive a reply. It may be waiting on Telcel to approve. They may not feel that their LTE network is robust enough to handle that much load yet. But I'm just guessing. We'll just have to wait and see what develops.
    Regads.

  • I've just upgraded to iOS 7 today.  Why can't I find AirDrop on my iPad?  Found it on my iPhone just fine.

    I've just upgraded to iOS 7 today.  Why can't I find AirDrop on my iPad?  Found it on my iPhone just fine.

    Siri is on iPad 3rd generation and later.  It is not available on your device.  Sorry.
    OOOPS.  Ipad Mini 2.  Missed that.  Disregard.

Maybe you are looking for

  • Licensing Office Home and Business 2013

    I know this has been talk about a bit... If I have 30 users to setup with Office 2013 H&B, do you recommend I setup a Public folder on my Exchange server, mail enable it, create a Microsoft account for the PC(email addr to match an SMTP alias of that

  • Internal hard drive stops working (OS 10.6)

    Hi all, I was working on my 2009 MacBook Pro (MacBook Pro, 2.53 GHz Intel Core 2 Duo) with a number of windows open (Chrome, Word, Mail, Preview), but nothing really heavy. All of a sudden all the pages in Chrome went blank, Word documents would only

  • Any ideas for making work an 2004 photo printer in Mavericks.

    The generic postscript driver does not have the 4x6'' paper the printer support. (It is a Sony DPP-FP30... and Sony does not have Mac drivers)

  • Inserting clip into sequence: aspect ratio adjustments

    I just made this page Aspect Ratio Adjustments available to whoever is curious to know what is the rational behind the values of +Aspect Ratio+ and Scale evaluated by FCE whenever it inserts a clip into a sequence. This was inspired by Michael in his

  • Front window

    My application may have any number of opened JFrames. Is there a way to determine which frame is currently the front most frame of a particular type? I tried tracking window events and focus events, but I may need to find a window that has not recent