Warnings with objective C protocols

I can't work out how to post code here without the formatting going all screwy, so here's an English description.
I have a formal protocol declaring "MyFunction". I have a class heirarchy, and an object which is an instance of something in that heirarchy. I check to see if the object conformsToProtocol, and if it does, I call MyFunction on it.
This works, but I get a compiler warning that the class might not respond to MyFunction. I know it will, because I check - how do I give the compiler enough information that it stops bugging me?
Thanks
Message was edited by: SquintAndSquirm

SquintAndSquirm wrote:
A lot of variations on the theme of { code } have all failed for me. Clearly forum posting is beyond my little programming brains capacity :}
Just reply to my earlier post where I have the code block and click the "quote" button. You will be able to see the tags I used. It is brace, "code", brace, followed by all your code, then another brace, "code", brace.
I am explicitly typing because I like having the compiler check my function calls for me, rather than using id and doing unchecked type casts everywhere to remove warnings.
I am using a protocol because Objective-C provides me with protocols and, if I'm paying the price for dynamic binding anyway, I may as well make use of it. I'm also using them because I'm learning Objective-C. Please don't tell me there's no way to make non-trivial use of protocols that doesn't result in compiler warnings :/
You shouldn't have to live with compiler warnings. If you are getting them, it is usually because you aren't doing something correctly. Those warnings are your friends. They will help you figure out the correct way to structure the code. What you need to do is have the desire to structure your code correctly instead of just "get rid of the warnings". I think you are on the right path in this respect.
As I mentioned earlier, using "id" is not necessarily a bad way to go. You can restrict it like "id<MyProtocol>" where the type is an "id" that must conform to "MyProtocol". You can do this if your interface is 100% restricted to MyProtocol. If you need to call other functions too, then you will have to use a base class.
The Base class does not implement the protocol because the base class, in this case, is apples NSViewController, but even if it wasn't, I am not prepared to shuffle all of my functionality up into a single base class just to make the compiler happy - there wouldn't be any point having a protocol atall if I was doing that - if I didn't want to use OO I'd still be programming in C.
It would sure be helpful to see some code. You can always use the "Preview" tab to figure out the code tags.
In any event, I still disagree with your architecture. An NSViewController is just an NSViewController. If that is your base class then you must restrict your interface to that which NSViewController provides. If you need more than that, there are several ways to do it. You could create an NSViewController category and add the functionality you want right into the class. You could use composition to have a class that contains an instance of NSViewController. You could derive a new class from NSViewController, make it conform to your protocol, and use that as your base class. I'm pretty sure I'm missing at least 4-5 other methods too.
I'm coming from a C++ background, where I can arrange for my code to either be correct (the function will be called) or fail to compile. From your answers it seems I can't quite get that far in objective-C, even with static typing, so dynamically checking the type and then casting to it is probably the best bet.
I think you just need to learn a bit more about Objective-C. I worked in C++ for 15 years, but I don't think I ever will in the future. I now do GUIs in Objective-C and CLI in Perl.
That leaves me with another question (simple syntax in this case), which is how to cast an object of type Base * into a protocol. I can't cast it to Derived * because there is more than one class derived from Base and I don't know which it is.
You can do Base<MyProtocol> but it doesn't really make sense. I think the fundamental problem is that you want a base class to be a base+ class - a base with a little extra. That just isn't good OO. The only way to make that work is casting. A base class provides its base class functionality - nothing more.

Similar Messages

  • The Bluetooth low energy protocol is not backward compatible with classic Bluetooth protocol. My iPhone 4s can not find my sonny in-dash player. However my iPhone 3GS does it. Very disappointed with this. Any idea how it can be fixed???

    The Bluetooth low energy protocol is not backward compatible with classic Bluetooth protocol.
    My iPhone 4s can not find my sonny in-dash player. However my iPhone 3GS does it. Very disappointed with this.
    Any idea how it can be fixed??????

    Hello,
    You are correct, Blue tooth low engergy, BTLE.(only) devices are not backward compatible with Classic bluetooth and cannot connect.
    However the Apple 4S and above have Bluetooth 4.0 support.. Hardware wise it has bothClassic Bluetooth, like the 3GS, as well as Bluetooth Low Energy.  There is no good reason why your 4s cannot communicate to your Sony in-dash player using the Classic bluetooth that resides in the 4S.
    I know that this does not answer the why it does not work, but it should work. Do you have to somehow re-pair the new phone up to the player?  Not  knowing the model of the Sony it is hard to investigate.
    And I hate to ask but are you sure that the Bluetooth radio is on in the phone?
    JT

  • BAPI_OBJCL_CHANGE error: valuated with object dependencies

    Hi expert,
    having programmed an extension for a customer for automatic maintenance of characteristic values of technical object, we have come across an error.
    When using BAPI_OBJCL_CHANGE to change a characteristic followed by BAPI_TRANSACTION_COMMIT (without wait) we have two scenarios:
    1. if the technical object has no value in the characteristic before calling  BAPI_OBJCL_CHANGE  the characteristic will be set.
    2. if there is already a value set there is an error stating
    Characteristic 'XYZ' valuated with object dependencies (old value '00')
    However, I can't find a dependency definition in CT04. do you know what's wrong here,or what is a usual cause of that?
    thanks
    Stefan

    Hi,
    Please see the given link, It may help you.
    Re: BAPI_OBJCL_CHANGE and BAPI_TRANSACTION_COMMIT
    Regards,
    Shamma

  • PDS Creation with Object Dependency

    Hello Gurus,
    I´ve written a function to run BAPI_PDSSRVAPS_SAVEMULTI in order to create PDS with object dependency (Super BOM). The PDS created by my function looks good in CURTO_SIMU, but it is not respecting the characteristic dependency during PPDS Heuristic. If I take a PDS generated in ECC with the exact same attributes, the heuristics explodes the components correctly. When I run the getlist bapi, it shows both ECC created and function created with all tables (pds_header, pds_component,) filled with the same content. Though, one PDS works and the other doesnt. I am clueless.
    thank you a lot.
    Cheers
    Rafael

    Mainly due locking issues. Added some logic to wait.

  • Batch input with objects

    Hi,
    Exists a standard class to develop a batch input????
    Any ideas???
    Is it possible to create a batch input with objects??

    Hi there
    Why not
    just define your class in the normal way
    decide what variables you need to pass
    in the methods of your class call the fm modules bdc open, bdc dynpro etc etc.
    Incidently the following include will have a decent amount of code for the BDC bits.
    include bdcrecx1.
    A good way is to start sm35 to record what you are doing on the screen. When you've finished  go to your recording in SM35 and click on CREATE PROGRAM - it will create most of the code for you including the screen fields -- you'll need to edit a bit of course as you don't need everything that will be shown.
    Debugging in the CREATE PROGRAM might show you a decent generic way of generating BDC's which you could easily do via a class.
    Note however using BDC's is the LEAST PREFRERRED WAY of performing work and should only be used as a LAST RESORT if there really is no other way. A lot of new BAPI's and Classes are now available which can do away with the need for BDC's  in most cases.
    job done.
    cheers
    jimbo

  • COPA Report Layout with Object List (ALV)

    Hi,
    I have question about the COPA report layout with object list (ALV). Everytime I executed the report with ALV format, the amount for quantity column always shows with 3 decimal number, menwhile for amount column always follow by 2 decimal number.
    Can anyone help me regarding this matter? I do not know how to turn off the decimal number to be 0 in this type of layout, although in the form itself I already put 0 decimal number.
    Thanks.

    Hi,
    Better to raise this issue in CO Forum. You can expect some solution.
    regards

  • Can't figure out why colors don't totally change when you select type with curser? It looks like it has by looking at it, but when you highlight the area after the old color is still there. It happens with objects to. Driving me NUTZ. Help!

    Can't figure out why colors don't totally change when you select type with curser? It looks like it has by looking at it, but when you highlight the area after the old color is still there. It happens with objects to. Driving me NUTZ. Help!

    Select the text, and open the Appearance palette (Come on guys, text highlight is irrelevant, it happens to objects too says the OP), and see what's listed there.  For a simple text object, there should only be a line item "Type", followed by "Characters", and when double-clicked the Characters line item expands to tell you the stroke and fill color.  For a basic object, there should be a fill and/or stroke.
    What happens sometimes, is that you end up adding extra strokes/fills to objects or text, and the appearance palette is where that will be noted.  Especially when you are dealing with groups, and/or picking up a color with the eyedropper, you may inadvertently be adding a fill or stroke on top of something.  You can drag those unwanted thingies from the Appearance palette into its own little trash can.

  • Problem with object view with primary-key based object identifier

    Hello!
    I met such problem.
    t1 is persinstent-capable class:
    class t1 : public PObject { .... };
    T1OV is object view, based on object table T1OT
    I1 is primary key of the table T1OT.
    Next code:
    t1* t = new (conn, "T1OV") t1(...);
    conn->commit();
    try
    t->markDelete();
    conn->commit(); // exception throws here
    Works fine if T1OV defined as:
    create view t1ov of t1 with object identifier default
    as select * from t1ot;
    And throws an exception
    "ORA-22883: object deletion failed"
    if:
    create view t1ov of t1 with object identifier (I1)
    as select * from t1ot;
    Such problem also occurs when object view is based on relational table/view (OID is primary-key based).
    Also it occurs when
    t->markModified() used insted of t->markDelete()
    I am using Oracle 9i second release for windows and
    MS VC++
    Thank You

    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_85a.htm#2065512
    You can specify constraints on views and object views. You define the constraint at the view level using the out_of_line_constraint clause. You define the constraint as part of column or attribute specification using the inline_constraint clause after the appropriate alias.
    Oracle does not enforce view constraints. However, operations on views are subject to the integrity constraints defined on the underlying base tables. This means that you can enforce constraints on views through constraints on base tables.
    Restrictions on View Constraints
    View constraints are a subset of table constraints and are subject to the following restrictions:
    You can specify only unique, primary key, and foreign key constraints on views. However, you can define the view using the WITH CHECK OPTION clause, which is equivalent to specifying a check constraint for the view.
    Because view constraints are not enforced directly, you cannot specify INITIALLY DEFERRED or DEFERRABLE.
    View constraints are supported only in DISABLE NOVALIDATE mode. You must specify the keywords DISABLE NOVALIDATE when you declare the view constraint, and you cannot specify any other mode.
    You cannot specify the using_index_clause, the exceptions_clause clause, or the ON DELETE clause of the references_clause.
    You cannot define view constraints on attributes of an object column.
    Rgds.

  • Can I group charts with objects in Numbers 3.0?

    In Numbers 2.1 I could group charts with objects and text.  I can't get this to work in Numbers 3.0.  The objects will group but not the charts.
    I used this to create marked-up charts in Numbers and paste them into a Pages document.
    (I just purchased a new iMac and don't have the old Numbers on it.)

    The only way around this is to print to PDF and open in preview, then use the rectangular selection tool to select the are you want to add to pages, then copy, then paste into Pages.
    You can post feedback to Apple using the menu item "Numbers > Provide Numbers Feedback"
    There are several features that were dropped and may be added back in... see this link:
    http://support.apple.com/kb/HT6049?viewlocale=en_US&locale=en_US

  • Docs with  object status

    list of document with object status, can somebody explain how does it work and how to activate a status
    how can we activate new user status for documents, pl help
    Edited by: varada rajan on Apr 3, 2008 7:31 AM
    Edited by: varada rajan on Apr 3, 2008 7:46 AM

    Hi,
    If you are talking about sales order status, this can be configured through status profile.
    SPRO-SD-SALES-SALES DOCUMENTS - DEFINE & ASSIGN STATUS PROFILE.
    Based on the user status you have maintained for your sales document, the status can be viewed in table JEST.
    For this first go to VBAK - get document condition header, and take this document condition header and go to table JEST.
    Here your current status will start with E**** and status inactive flag would be blank.
    Hope this helps you.
    Reward points for contribution if it does.
    Regards
    Ravi

  • Mapping refcursors with object types in a procedure

    Hi all,
    I need some help regarding the mapping of refcursors with object types .
    Example: Procedure "A" has object types as input/output parameters which lies in the Web Method Application as a API.
    We are creating a procedure "B" which has ref cursors as input/ouput parameters
    which will map to the Procedure "A"'s object type parameters.
    It will be highly needful for the solution.
    Regards
    Saugata

    Your pseudocode has a lot of steps in it, but you didn't say which step you need help with. Since I already covered going from a nested table type to a refcursor, I'll assume you want an example that goes the other way now, like from a refcursor to a nested table type. Here's one ...
    SQL>
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> create type nested_table_type as table of varchar2(14) ;
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL> create function func
      2    ( p_cursor in sys_refcursor )
      3    return nested_table_type
      4  as
      5    v_nested_table nested_table_type ;
      6  begin
      7
      8    fetch p_cursor bulk collect into v_nested_table ;
      9    return( v_nested_table );
    10
    11  end;
    12  /
    Function created.
    SQL> show errors
    No errors.
    SQL>
    SQL> select func( cursor( select dname from dept ) ) as nested_table from dual ;
    NESTED_TABLE
    NESTED_TABLE_TYPE('ACCOUNTING', 'RESEARCH', 'SALES', 'OPERATIONS')If your cursor selects objects instead of simple data types, the code is pretty much the same.
    SQL> create type object_type as object ( c1 varchar2(14), c2 varchar2(13) );
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL> create type nested_table_type as table of object_type ;
      2  /
    Type created.
    SQL> show errors
    No errors.
    SQL>
    SQL>
    SQL>
    SQL> create function func
      2    ( p_cursor in sys_refcursor )
      3    return nested_table_type
      4  as
      5    v_nested_table nested_table_type ;
      6  begin
      7
      8    fetch p_cursor bulk collect into v_nested_table ;
      9    return( v_nested_table );
    10
    11  end;
    12  /
    Function created.
    SQL> show errors
    No errors.
    SQL>
    SQL> select
      2    func( cursor( select object_type( dname, loc ) from dept ) ) as object_table
      3  from dual ;
    OBJECT_TABLE(C1, C2)
    NESTED_TABLE_TYPE
      ( OBJECT_TYPE('ACCOUNTING', 'NEW YORK'),
        OBJECT_TYPE('RESEARCH', 'DALLAS'),
        OBJECT_TYPE('SALES', 'CHICAGO'),
        OBJECT_TYPE('OPERATIONS', 'BOSTON')
      )(NB I manually reformated the query results for clarity).

  • Troubles with the modbus protocol

    Hello there,   I have a trouble here with the Modbus protocol; I have already read the forums and saw that there are some issues with modbus tcp;  I have the latest  DSC 8.0 module and also Labview 8.0;  I think that maybe this issues have been fixed.
    There is a demo of Modbus in the examples and it work fine on my computer and and also on two different computer; But if I want to create my own simple application to see if it works , it doesn't work;  
    Attached you can see a zip file with the two projects;  Please someone check it for me  and let me know what the problems are;  If I have this simple app. working then I will move on to my  really application.
    Thanks,
    scorpio
    Attachments:
    Modbus testing.zip ‏36 KB

    Dear Nick,
    The master I/O server in my project is pointing to my  local host 127.0.0.1;  For the modbus slave you cannot configure the IP address; 
    A collegue is also trying to find the problem.  Attached you can see a word document he made illustrating the problem.
    Thanks,
    scorpio
    Attachments:
    National Instuments.doc ‏223 KB

  • Generate error list with object detail

    Dear All,
    I have two way (multimaster ) Replication but due to some reason it generated many errors during replicate data so to resolve errors, I want to generate error list (Report) with object details instead viewing them one by one. please guide
    Thanks

    What do you mean with generate error list (Report) with object details ?
    You can get all the errors from DEFERROR view.
    There are columns DEFERRED_TRAN_ID and CALLNO.
    You can join this columns with DEFCALL (DEFERRED_TRAN_ID and CALLNO).
    Joining this two views will provide information about the objects and transaction type involved in the call.
    DEFCALL.PACKAGENAME contains the reference to the table_name.
    DEFCALL.PROCNAME contains information about the transaction type.
    Example:
    select e.deferred_tran_id,
           e.callno,
           e.origin_tran_db,
           c.packagename,
           c.procname
    from deferror e, defcall c
    where e.deferred_tran_id=c.deferred_tran_id
    and e.callno=c.callno(below are the links to the 10gR2 docs containing information about DEFERROR and DEFCALL views. If your database is different version, than search http://tahiti.oracle.com for version specific documentation)
    DEFERROR
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14227/rardeftranviews.htm#sthref2599
    DEFCALL
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14227/rardeftranviews.htm#sthref2595
    Cheers!
    Message was edited by:
    tekicora

  • Invalid endpoint uri with a new protocol (custom protocol)

    Hi!
    I've deployed a web service in the OSB console which has an endpoint with http protocol...(f.e. "http://myhost:port/WebService"), importing a jar which contains this files: proxy service, business service, schema and wsdl...
    I added to the weblogic server a new custom protocol.The endpoint of this new protocol must be like this: "tcp://host:port"...
    I've tried to redeploy the web service with the new protocol in the business service file...but when i redeploy the web service, the osb says that the uri is incorrect, because it's still having the last web service's uri : "http://myhost:port/WebService" and it doesn't match the new protocol's endpoint ( "tcp://...")...
    when i do the same change in the business service...(change the business service's protocol)...the osb automatically removes the existing uri and it shows me a new endpoint uri with the new protocol to add...
    does exist any way to remove the existing business service's endpoint uri when i redeploy the web service's jar in the osb console????
    Thanks!!
    Ingrid.
    Edited by: user11144501 on 17-ene-2011 7:46

    Changing URI and transport protocol itself are two different things. If you want to change URI only then that is very much possible using Customization File in OSB -
    http://download.oracle.com/docs/cd/E14571_01/doc.1111/e15867/customization.htm#CACJCAGD
    You may execute customization files using WLST as well.
    But in your case you want to change the transport protocol itself which may require changes in Transport Protocol Parameters (and other dependent settings), so it may not be possible to do the same using script. I think for changing transport protocol, you have to manually update all the service's configurations on sbconsole or in OEPE.
    Regards,
    Anuj

  • No authorization for action: CRE with object: ADCP

    Hi,
    I encountered the following error when creating an index:
    No authorization for action: CRE with object: ADCP
    I was at transaction DB02 -> 'Checks' -> Database<->ABAP/4 Dictionary.
    The checks indicate that there are some optional indexes that are not created.
    The error is encountered when I select one of these indexes (eg. ADCP-I01) and try to create it using the 'Create in DB' button.
    Do I have to assign some certain permission to my account? I am already holding the SAP_ALL and S_A.SYSTEM profiles.
    Thanks for any help,
    Tzyy Ming

    Hello,
    As i had expected DDIC userid did the needful.
    to see whether the index is created, you need to do the following.
    start transaction DB02
    click on the refresh button
    You would then get a new pop up with two different buttons.
    now on this pop up click the 'perform database checks' button.
    System might give you a warning 'This will take time' , click yes and wait for the system to refresh the data.
    Once system has refreshed the database data, you should be able to see your newly created index.
    Regards,
    Siddhesh

Maybe you are looking for

  • TS1538 Running Windows XP,Ipod Mini works fine,but Ipod Nano visible in Windows,but not Itunes.Have loaded latest version of ITunes.How do I prceed

    Am running Windows XP pro,Ipod Mini works fine,but Ipod Nano is visible in my computer as a mass storage device,but not in Itunes.The settings on the Ipod says Version 1.0.2 Mac.Have tried all the trouble shooting solutions under Itunes help,but no s

  • Bapi or function module to create conter readings in service order

    hi all, i have used crm_service_order_create to create the service order it was very helpful . I could also create the service order with the i base component. But i need to enter the counter readings against the i base component. Is there any bapi o

  • Create Spoolrequest for PO

    Hi, I have a question how to create a spool request for a sapscript PO form. In my case I want to write a program which sends a PO via Email. For this I need to create a spool request for the mail to convert it to PDF and send it out. Converting to P

  • WAD query results in JUNK

    Hi Experts, I am working on BW - 3.5. There is a problem with the reports in WAD. All the Queries which are available (old queries) are working fine in Internet Explorer and in Mozilla Firefox, but when i create a new Query in WAD or when i "save as"

  • Collection Rate issue - hanging in LabView Code

    Hi guys, I'm current programming a DAS in LabVIEW and am having problems with how often the graphs in front panel are updating.  For some reason, no matter what I set the input "Collection Rate" to, it always updates every 10 seconds (regardless of w