Initializing an array of 13 button objects - a more compact way?

This works, but I was wondering if there was a more compact syntax for what I am doing.
I'm creating an array that contains 13 UIButton objects as follows:
NSArray * myButtonObjects;
myButtonObjects = [NSArray arrayWithObjects: [UIButton buttonWithType:UIButtonTypeRoundedRect],
[UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
[UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
[UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
[UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
[UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect],
[UIButton buttonWithType:UIButtonTypeRoundedRect], [UIButton buttonWithType:UIButtonTypeRoundedRect], nil];
Is there a shorter way of doing this, like specifying the number of UIButton objects I want to create the NSArray with?
Thanks,
doug

Since my first long statement where I repeated the UIButton object 13 times worked, I thought this would work as well:
NSArray *theButtons;
for (i=0; i<13; i++) {
[theButtons arrayByAddingObject:[UIButton buttonWithType:UIButtonTypeRoundedRect]];
That compiles, but it doesn't work like the original. The program crashes when it tries to run that loop.
doug

Similar Messages

  • How to set an array element in an object type of array??

    Hi,
    I have set attribute as follow:
    Color[] colors;
    Color[] colors = new Color[20];
    colors[0] = "Red";
    colors[1] = "blue";I can't compile this code. It said:
    "Incompatible type -found java.lang.String but expected Colors
    Could you tell me how to set an array elements when the array type is an object?

    in your case, the array shouldn't be Color[] but String[] since you re intending to put strings into it
    by the way, you could also use a hashmap to map a string to a color:
    HashMap<String, Color> hm = new HashMap<String, Color>();
    hm.put("Red", Color.RED);
    hm.put("Blue", Color.BLUE);
    etc.

  • Can't create table that grows using the button object

    Im a beginner, and this seems like a simple issue. Appreciate your help in advance.  When I try to do this, the button fails to add a row.
    So, I printed out the Help section entitled, "create a table that grows using the button object" and started from scratch with a simple table as the only object on the form- and followed the instructions to the letter.
    When I go to preview and click the button, a row is not added.
    Can you suggest something?

    Try this:
    Select body row of table from hierarchy palette that you want to repeat then on he object tab of the properties tab select binding tab. You need to click on "Repeat Row for Each Data Item"
    I hope this helps
    Murat
    www.muratkuru.com.tr

  • Error when trying top connect ChooseFromList object to a Button object

    Hi all
    I have a user form with a button .
    upon pressing on the button i want that a ChooseFromList screen will be opened. when i create the ChooseFromList object and bind it to the button object by assigning its UID to the button's ChooseFromListUID property i recieve an error message that says: "Invalid choose from list".
    what could be causuing this problem? what is the correct way in code to connect a ChooseFromList object to a Button object?
    appreciate the help
    Yoav

    Hi Yoav,
    Before Doing the Bind, you should add your CFL
    Dim oCFLs As SAPbouiCOM.ChooseFromListCollection
    Dim oCFL As SAPbouiCOM.ChooseFromList
            Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams
    oCFLs = oFrm.ChooseFromLists
                oCFLCreationParams = SBO_App.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
                '1. BP CFL
                oCFLCreationParams.MultiSelection = False
                oCFLCreationParams.ObjectType = SAPbobsCOM.BoObjectTypes.oBusinessPartners
                oCFLCreationParams.UniqueID = cflName
                oCFL = oCFLs.Add(oCFLCreationParams)
    The correct way to connect a CFL to a button is like this
    Dim oBtn As SAPbouiCOM.Button
    oBtn = oFrm.Items.Item("btnCFL").Specific
    oBtn.ChooseFromListUID = cflName

  • How to add image in the button Objects.

    Dear All,
    I need image in the button object. I don't know whether it is possible or not.
    If anyone know the idea for solving this problem Please siggest me.
    Thank you
    saroj neupane

    You cannot put an image on a button put you can have an image then create a clear button that you can put over top of the image. Send the image to the background then set the background fill of the button to none. This will make the button transparent. You may need to play with the borders of both obejcts to get the effect you want.

  • Linked Button object question

    Hey Everyone,
    I have created some code to replicate the choose item functionality for master item data. I take the itemcode selected and put this in a text box.
    How do I use the Linked BUtton object to allow the user to click the yellow arrow and view this object? Do I have to code the click event, etc.. on my own? Or is there built in SDK functions to make this work?
    Any help would be appreciated.

    Hi Laura!
    As i know 'ChooseFromList'-service will be exposed in v2005.
    More at https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/businessone/s-u/sap business one 2005 release notes.htm#_toc103594943
    There is also no any standard method to relate LinkButton and your 'ChooseFromList'-implementation.
    All you need is to handle LinkButton-click and then execute your code for 'ChooseList'.
    The code-scheme in ItemEvent-handler can be like that:
    if (event = ItemPressed && item = LinkedButton)
       myChList = new ChList();
       oEditText.Value = myChList.SelectItem()
    hope it'll help

  • Is Array in java are Object?

    is Array in java are Object?
    int a[]=new int[10];
    new will allocate memory. but int is a type not an Class ?
    please help me.......

    An array in Java is an object. Array elements may be primitives or references, depending on the way the array is declared.

  • Please tell me how I can set an array field to an object?

    Hi,
    Please tell me how I can set the plID (an array field) to an object? This result is for one Agent object. Suppose the Agent object only has these two fields.
    If a sql query result is something like this (which is one object).
    agent_last PLID
    smith      5
    smith               6
    smith               7
    Agent agent = new Agent();
    StringBuffer sql = new StringBuffer();
    int count = getPLNo(agentID);// # of the query result
    try {
    SQL tsql = new SQL();
    Connection conn = tsql.getConnection();
    sql.append("SELECT agent_last, b.PLID ");
    sql.append("FROM Agent a, PL b ");
    sql.append("where a.agent_id = b.agent_id ");
    sql.append("and a.agent_id = ? ");
    PreparedStatement st = conn.prepareStatement(sql.toString());
    st.setInt(1, agentID);
    ResultSet rs = st.executeQuery();
    while (rs.next()) {
    agent.setAgentID(agentID);
    agent.setAgentLast(rs.getString(1));
    for ( int i = 0 ; i < count; i++ ) {               //how to do it?
    agent.setPrivateLabelID(new int[] {rs.getInt(2)});//how to do it?
    st.close();
    rs.close();
    tsql.close();
    } catch (SQLException e) {
    System.out.println("SQL: " + e.getMessage());
    throw new Exception(e.getMessage());
    } catch (Exception e) {
    System.out.println("Except: " + e.getMessage());
    throw new Exception(e.getMessage());
    return agent;
    }

    If that's not what you're looking for, then you get
    what you pay for. :-)Hi fmeyer75,
    Thank you very much for your input. That's exactly what I was looking for and it works!!!!
    For anyone who has similar issue, I changed the code a little to make it work with my existing ones. I never splited queries before, so please tell me if there's a better way to handle it.
    I keep the first half part and changed a little for the second half. Below is what I use now
    sql.setLength(0);
    sql.append("SELECT PLID ");
    sql.append("FROM PL ");
    sql.append("where agent_id = ? ");
    List list = new ArrayList();
    PreparedStatement st2 = conn.prepareStatement(sql.toString());
    st2.setInt(1, agentID);
    ResultSet rs2 = st2.executeQuery();
    while (rs2.next()) {
                 list.add(new Integer(rs2.getInt(1)));
    agent.setPrivateLabelID(new int[list.size()]) ;
    for ( int i = 0 ; i < list.size(); i++ ) {
    agent.getPrivateLabelID() = ((Integer)
    list.get(i)).intValue() ;
    st.close();
    rs.close();
    st2.close();
    rs2.close();

  • Initializing string array registers

    Hello. I have posted my project. It is not even close to finished but I am having trouble initializing the array's labeled "Up values" and "Down values", to "0" for all elements, at beginning of Vi run. So, when I am at the Front Panel and running the Vi, I would like all of the fields to begin with a "0", the moment the Vi is started. I have tried a couple different things I could think of and watched the Core 1 Video about arrays again however, it doesn't give the example for a string and nothing I have tried so far, is working. Thank you.

    crossrulz wrote:
    There are a few options to you:
    1. Use an initialization state to write to your indicators their default values via a local variable
    2. Put the default values into the indicators and then right-click on them and choose Data Operations->Make Current Value Default.  This will store the default value in the indicators themselves.
    I would recommend going with #1.
    2. Put the default values into the indicators and then right-click on them and choose Data Operations->Make Current Value Default.  This will store the default value in the indicators themselves. I put a "0" in each field, I slected "make current value default, but after the Vi ran, and then I started the Vi again, it keeps the numbers in the registers that are left over from the previous test. I also tried your suggestion #1. however, it still isn't writing a "0" in all the fields. The reason for this is that I don't want the operator's to read old data accidentally, when the Vi is running. I thought if I wipe all the registers out, it will prevent that from happening.

  • My mac book wont recognize my ipod. My Ipod will make the initial connected sound saying its charging but otherwise theres no way of finding the Ipod anywhere on the computer or Itunes.

    My mac book wont recognize my ipod. My Ipod will make the initial connected sound saying its charging but otherwise theres no way of finding the Ipod anywhere on the computer or Itunes. Please help with anyway I can get the Ipod recognized so I can download music from Itunes to my Ipod. Thanks in advance.

    Hello xerxes.nashion,
    It sounds like your iPod is not recognized by iTunes or your MacBook Pro.  I recommend following the steps in the article below for an issue like this:
    iPod not recognized in iTunes and Mac desktop
    http://support.apple.com/kb/TS1410
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Can we delegate a business object to more than one Subtypes?

    Can we delegate a business object to more than one Subtypes?
    So unless we delegate that Sub type , will the new method of that sub type  be not called from our WF?
    Edited by: kittu reddy on Nov 25, 2008 7:50 AM

    No this is not possible. I will like to know what is the business case you will require this.
    Thanks
    Arghadip

  • HT3988 My mouse button only allows scrolling one way.  Is there a way to disassemble and clean the mouse.  I have model A1152.

    My mouse button only allows scrolling one way.  Is there a way to disassemble and clean the mouse.  I have model A1152.

    Found the following with a google search (among others):
    How to clean an Apple Mighty Mouse - Take-apart guide (youtube video)
    Cleaning Up The Apple Mighty Mouse

  • When i do initializing for opening balance(2lis_03_bx) i'm getting more add

    when i do initializing for opening balance(2lis_03_bx) i'm getting more added records than transfered records.

    Hi,
    It happens. It does not create any problem.
    But Right now, I do not have answer to the question why system does like this.
    Lets hear what other says.
    With rgds,
    Anil Kumar Sharma .P

  • After I have deleted a file from my iphone, it still shows the song with a download button? Is there a way to get rid of this totally, so it doesn't show at all?

    After I have deleted a file from my iphone, it still shows the song with a download button? Is there a way to get rid of this totally, so it doesn't show at all?

    The banner usually indicates that the memo is "Paused." If you go back into voice memos, touch the word "Done" beside the big red pause button, give it a name, then it will show in a list. Touch the memo in the list then touch the trash can icon that should appear.

  • Why can't get the object "out" in this way?

    We use "PrintWriter out=response.getWriter()"to get a "out" object in Servlet and output text to webbrowser with it.But I think the PrintWriter is a class and Why can't I get the object "out" use this way:"PrintWriter out=new PrintWriter()"?I think the later is easier to understand.Anyone can help me?

    I check the Servlet API.The PrintWriter has a constructor with a abstract object Writer as it's parameter.I couldn't create the Writer object so I can't create the out object.Why it's constructor is protected by java?

Maybe you are looking for

  • Error While Run time

    Hi, Pls help me to solve my problem. My coding is comple well while run time it showing me the error, Fatal Error: The value of attribute "xsi:schemaLocation" associated with an element type "null" must not contain the '<' character. The value of att

  • How to get rid of bookmark star?

    How to get rid of bookmark star? I tried: @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); #bookmarks-menu-button toolbarbutton { visibility:collapse !important; } by creating and putting it in a file "userChrome.css"

  • Deception with VIDEOS in Zen V Plus (Deceiv

    En espa?ol: Creative pretende que el ZEN V Plus sea el competidor directo del IPod Nano de Apple, y para mi humilde opini?n casi lo ha conseguido, supera en todo al Nano, pero falla en una cosa, LOS VIDEOS, la compresi?n y conversi?n es muy mala, el

  • Connecting MBP to DV Cassette Recorder and External HD

    Before getting my MBP, I had a G4 eMac, which had two 6PF firewire outlets. The firewire cables from my external HDs had the matching plugs, and I got a 4PF-6PM adapter for the firewire cable on my DV deck. The firewire port on the new MBP looks diff

  • 16:9 ASPECT RATIO IMPORT PROBLEM

    Hi I have a camera using SDHS cards. I set it for 16:9 aspect ratio recording. I know the output is 16:9 because it is when I use a SDHC card reader and view it on the PC with the viewer or play it elswhere it is 16:9 I set the new project to 16:9. i