问:
Gradle build finished with 1 error(s)
error getting while running project in android studio

I already tried to solve my problem by changing sdk

答: u can clear gradle,have a try.do u hava a screenshot for me</p>

Title: Gradle build finished with 1 error(s)


来源: stackexchange

问:
C99 compatible nested calls within variadic macros
Need a way to support nested calls in variadic macros with optional argument. same as this but C99 compatible

GNU gcc extension for ## operator prevents nested calls from being expanded, see code below.

```<code>#define send(obj, msg, ...) find_method(obj, msg)(obj, ##__VA_ARGS__)

/* Ok */
send(0, "+", 1);
find_method(0, "+")(0, 1);

/* Ok. nested call as macros named argument */
send(send(5, "increment"), "+", 1);
find_method(find_method(5, "increment")(5), "+")(find_method(5, "increment")(5), 1);

/* Fail. nested call as macros variable argument i.e. `send` macro is not expanded */
send(0, "+", send(5, "increment"));
find_method(0, "+")(0, send(5, "increment"));

/*
 * preprocess with next commands
 *
 * gcc-4.9   -Wall -std=c99 -E -c file.c | less
 * clang-3.8 -Wall -std=c99 -E -c file.c | less
 */
</code>```

I've modified Jens Gustedt solution to place optional comma, see code below.

Are there more concise alternatives ?

```<code>#define _ARG16(              \
    _0,  _1,  _2,  _3,  _4,  \
    _5,  _6,  _7,  _8,  _9,  \
    _10, _11, _12, _13, _14, \
    _15, ...) _15
#define HAS_COMMA(...) \
    _ARG16(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
#define _TRIGGER_PARENTHESIS_(...) ,

#define OPTIONAL_COMMA(...)                                             \
    _ISEMPTY(                                                           \
          /* test if there is just one argument, eventually an empty    \
             one */                                                     \
          HAS_COMMA(__VA_ARGS__),                                       \
          /* test if _TRIGGER_PARENTHESIS_ together with the argument   \
             adds a comma */                                            \
          HAS_COMMA(_TRIGGER_PARENTHESIS_ __VA_ARGS__),                 \
          /* test if the argument together with a parenthesis           \
             adds a comma */                                            \
          HAS_COMMA(__VA_ARGS__ (/*empty*/)),                           \
          /* test if placing it between _TRIGGER_PARENTHESIS_ and the   \
             parenthesis adds a comma */                                \
          HAS_COMMA(_TRIGGER_PARENTHESIS_ __VA_ARGS__ (/*empty*/))      \
    )

#define SPACE_SYMBOL
#define COMMA_SYMBOL ,
#define ARG3(_0, _1, _2, ...) _2
#define OPTIONAL_COMMA_FROM(...) ARG3(__VA_ARGS__, SPACE_SYMBOL, COMMA_SYMBOL)

#define PASTE5(_0, _1, _2, _3, _4) _0 ## _1 ## _2 ## _3 ## _4
#define _ISEMPTY(_0, _1, _2, _3) \
    OPTIONAL_COMMA_FROM(PASTE5(_IS_EMPTY_CASE_, _0, _1, _2, _3))
#define _IS_EMPTY_CASE_0001 ,

#define send(obj, msg, ...) \
    find_method(obj, msg)(obj OPTIONAL_COMMA(__VA_ARGS__) __VA_ARGS__)

/* Ok */
send(0, "+", 1);

/* Ok */
send(send(5, "increment"), "+", 1);

/* Ok */
send(0, "+", send(5, "increment"));
</code>```

Update:

H Walters thanks for idea.

Didn't noticed approach with macros overloading in first place

```<code>#define SEND_NO_ARG(obj, msg) find_method(obj, msg)(obj)
#define SEND_ARG(obj, msg, ...) find_method(obj, msg)(obj, __VA_ARGS__)

#define GET_18TH_ARG(arg1, arg2, arg3, arg4, arg5,        \
    arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,   \
    arg14, arg15, arg16, arg17, arg18, ...) arg18
#define SEND_MACRO_SELECTOR(...)                          \
    GET_18TH_ARG(__VA_ARGS__,                             \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_NO_ARG, )

#define send(...) SEND_MACRO_SELECTOR(__VA_ARGS__)(__VA_ARGS__)
</code>```

答:
macros overloading technique provides shortest code so far.</p>

```<code>#define SEND_NO_ARG(obj, msg) find_method(obj, msg)(obj)
#define SEND_ARG(obj, msg, ...) find_method(obj, msg)(obj, __VA_ARGS__)

#define GET_18TH_ARG(arg1, arg2, arg3, arg4, arg5,        \
    arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,   \
    arg14, arg15, arg16, arg17, arg18, ...) arg18
#define SEND_MACRO_SELECTOR(...)                          \
    GET_18TH_ARG(__VA_ARGS__,                             \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_NO_ARG, )

#define send(...) SEND_MACRO_SELECTOR(__VA_ARGS__)(__VA_ARGS__)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Need a way to support nested calls in variadic macros with optional argument. same as this but C99 compatible

GNU gcc extension for ## operator prevents nested calls from being expanded, see code below.

#define send(obj, msg, ...) find_method(obj, msg)(obj, ##__VA_ARGS__)

/* Ok */
send(0, "+", 1);
find_method(0, "+")(0, 1);

/* Ok. nested call as macros named argument */
send(send(5, "increment"), "+", 1);
find_method(find_method(5, "increment")(5), "+")(find_method(5, "increment")(5), 1);

/* Fail. nested call as macros variable argument i.e. `send` macro is not expanded */
send(0, "+", send(5, "increment"));
find_method(0, "+")(0, send(5, "increment"));

/*
 * preprocess with next commands
 *
 * gcc-4.9   -Wall -std=c99 -E -c file.c | less
 * clang-3.8 -Wall -std=c99 -E -c file.c | less
 */

I've modified Jens Gustedt solution to place optional comma, see code below.

Are there more concise alternatives ?

#define _ARG16(              \
    _0,  _1,  _2,  _3,  _4,  \
    _5,  _6,  _7,  _8,  _9,  \
    _10, _11, _12, _13, _14, \
    _15, ...) _15
#define HAS_COMMA(...) \
    _ARG16(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
#define _TRIGGER_PARENTHESIS_(...) ,

#define OPTIONAL_COMMA(...)                                             \
    _ISEMPTY(                                                           \
          /* test if there is just one argument, eventually an empty    \
             one */                                                     \
          HAS_COMMA(__VA_ARGS__),                                       \
          /* test if _TRIGGER_PARENTHESIS_ together with the argument   \
             adds a comma */                                            \
          HAS_COMMA(_TRIGGER_PARENTHESIS_ __VA_ARGS__),                 \
          /* test if the argument together with a parenthesis           \
             adds a comma */                                            \
          HAS_COMMA(__VA_ARGS__ (/*empty*/)),                           \
          /* test if placing it between _TRIGGER_PARENTHESIS_ and the   \
             parenthesis adds a comma */                                \
          HAS_COMMA(_TRIGGER_PARENTHESIS_ __VA_ARGS__ (/*empty*/))      \
    )

#define SPACE_SYMBOL
#define COMMA_SYMBOL ,
#define ARG3(_0, _1, _2, ...) _2
#define OPTIONAL_COMMA_FROM(...) ARG3(__VA_ARGS__, SPACE_SYMBOL, COMMA_SYMBOL)

#define PASTE5(_0, _1, _2, _3, _4) _0 ## _1 ## _2 ## _3 ## _4
#define _ISEMPTY(_0, _1, _2, _3) \
    OPTIONAL_COMMA_FROM(PASTE5(_IS_EMPTY_CASE_, _0, _1, _2, _3))
#define _IS_EMPTY_CASE_0001 ,

#define send(obj, msg, ...) \
    find_method(obj, msg)(obj OPTIONAL_COMMA(__VA_ARGS__) __VA_ARGS__)

/* Ok */
send(0, "+", 1);

/* Ok */
send(send(5, "increment"), "+", 1);

/* Ok */
send(0, "+", send(5, "increment"));

Update:

H Walters thanks for idea.

Didn't noticed approach with macros overloading in first place

#define SEND_NO_ARG(obj, msg) find_method(obj, msg)(obj)
#define SEND_ARG(obj, msg, ...) find_method(obj, msg)(obj, __VA_ARGS__)

#define GET_18TH_ARG(arg1, arg2, arg3, arg4, arg5,        \
    arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,   \
    arg14, arg15, arg16, arg17, arg18, ...) arg18
#define SEND_MACRO_SELECTOR(...)                          \
    GET_18TH_ARG(__VA_ARGS__,                             \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_NO_ARG, )

#define send(...) SEND_MACRO_SELECTOR(__VA_ARGS__)(__VA_ARGS__)

Body:
macros overloading technique provides shortest code so far.

#define SEND_NO_ARG(obj, msg) find_method(obj, msg)(obj)
#define SEND_ARG(obj, msg, ...) find_method(obj, msg)(obj, __VA_ARGS__)

#define GET_18TH_ARG(arg1, arg2, arg3, arg4, arg5,        \
    arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13,   \
    arg14, arg15, arg16, arg17, arg18, ...) arg18
#define SEND_MACRO_SELECTOR(...)                          \
    GET_18TH_ARG(__VA_ARGS__,                             \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, SEND_ARG, \
        SEND_NO_ARG, )

#define send(...) SEND_MACRO_SELECTOR(__VA_ARGS__)(__VA_ARGS__)


问:
Highmaps/Highcharts Congressional District Map Using Google Spreadsheets
I cannot figure out for the life of me why the hc-key for congressional districts cannot or is not getting associated correctly. I've tried just about every variation of the Highmaps and Highcharts joinBy that I can. I've also looked at every answer on Stack.

We've had no problem using spreadsheets for states, but this just isn't working out for us.

I'll include the fiddle link, but here's the code. I'm even leaving in commented out code just so you can see what attempts I've made that haven't worked out for me. Also, we have to tweak the districts provided by Highmaps to update them so consider the paths if you try to duplicate it.

Any help would be greatly appreciated!

```<code>jQuery(document).ready(function($) {
  Highcharts.data({
    // https://docs.google.com/spreadsheets/d/1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM/pubhtml
    googleSpreadsheetKey: '1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM',
    // custom handler when the spreadsheet is parsed
    parsed: function(columns) {
      // Read the columns into the data array
      var data = [];
      function pointClick() {
        var row = this.options.row,
        district = this.district,
          incumbent = this.incumbent,
          $div = $('<div></div>')
          .dialog({
            title: function() {
              $(this).closest("span.ui-dialog-title")
                .html('<span class="state-title"></span><h2 class="state-text">' + district + ' ' + incumbent + '</h2>');
            },
            open: function() {
              $(this).closest(".ui-dialog")
                .find(".ui-button-text-only")
                .removeClass(".ui-button-text-only")
                .addClass("ui-button-icon-only")
                .html("<span class='ui-button-icon ui-icon ui-icon-closethick'></span>");
            },
            width: 740,
            height: 740
          });
        window.chart = new Highcharts.Chart($div[0], {
          credits: {
            href: 'https://www.peoplespunditdaily.com/',
            text: 'People‘s Pundit Daily'
          },
          title: {
            text: 'Election Projection Data'
          },
          subtitle: {
            text: 'Recent Election Results'
          },
          /*tooltip: {
            useHTML: true,
            headerFormat: '<span style="font-size:12px">{series.name}</span><hr class="style-two">',
            pointFormat: '{point.name}: <b>{point.percentage:.1f}% to {point.challengerVote}</b>'
          },*/
          plotOptions: {
            pie: {
              dataLabels: {
                enabled: true,
                distance: 10,
                style: {
                  fontWeight: 'bold',
                  color: 'black'
                }
              },
              startAngle: -90,
              endAngle: 90,
              center: ['50%', '75%']
            }
          },
          series: [{
            type: 'pie',
            name: '2016 House Results',
            innerSize: '50%',
            data: [{
              name: 'Incumbent Vote',
              color: '#006aab',
              y: parseFloat(columns[incumbentVote][row], 10)
            }, {
              name: 'Challenger Vote',
              color: '#b02029',
              y: parseFloat(columns[challengerVote][row], 10)
            }],
            dataLabels: {
              enabled: true,
            },
            cursor: 'pointer',
            showInLegend: false,
            center: [160, 100],
            size: 120
          }, {
            type: 'pie',
            name: '2016 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Trump Vote Share',
              color: '#b02029',
              y: parseFloat(columns[trump][row], 10)
            }, {
              name: 'Clinton Vote Share',
              color: '#006aab',
              y: parseFloat(columns[clinton][row], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: [500, 100],
            size: 120
          }, {
            type: 'pie',
            name: '2012 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Obama Vote Share',
              color: '#006aab',
              y: parseFloat(columns[obama][row], 10)
            }, {
              name: 'Romney Vote Share',
              color: '#b02029',
              y: parseFloat(columns[romney][row], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: [160, 300],
            size: 120
          }]
        });
      }
      options = {
        chart: {
          renderTo: 'container',
          backgroundColor: null
        },
        credits: {
          enabled: false
        },
        title: {
          style: {
            textShadow: '0 0.032em 0 #999, 0px 0.15em 0.11em rgba(0,0,0,0.15), 0px 0.25em 0.021em rgba(0,0,0,0.1), 0px 0.32em 0.32em rgba(0,0,0,0.1)',
            color: '#020202'
          },
          text: '2016 House of Representatives Battleground District Map'
        },
        subtitle: {
          style: {
            color: '#1d1c1d'
          },
          text: 'Source: PPD Election Projection Model'
        },
        legend: {
          layout: 'vertical',
          align: 'right',
          navigation: {
            enabled: true
          },
          verticalAlign: 'bottom'
        },
        mapNavigation: {
          enabled: false
        },
        colorAxis: {
          dataClasses: [{
            from: -100,
            to: -75,
            color: '#006aab',
            name: 'Democrat'
          }, {
            from: -75,
            to: -50,
            color: '#6193c7',
            name: 'Likely Democrat'
          }, {
            from: -50,
            to: -25,
            color: '#9cc0e3',
            name: 'Leans Democrat'
          }, {
            from: -25,
            to: -10,
            color: '#ceeafd',
            name: 'Trump District Leans Democrat'
          }, {
            from: -10,
            to: 10,
            color: '#C39BD3',
            name: 'Battleground'
          }, {
            from: 10,
            to: 25,
            color: '#fbd0d0',
            name: 'Clinton District Leans Republican'
          }, {
            from: 25,
            to: 50,
            color: '#e99d98',
            name: 'Leans Republican'
          }, {
            from: 50,
            to: 75,
            color: '#cf635d',
            name: 'Likely Republican'
          }, {
            from: 75,
            to: 100,
            color: '#b02029',
            name: 'Republican'
          }]
        },
        tooltip: {
          useHTML: true,
          borderWidth: 2,
          backgroundColor: {
            linearGradient: [0, 0, 0, 60],
            stops: [
              [0, '#F6F5F4'],
              [1, '#FFFFFF']
            ]
          },
          headerFormat: '<span style="font-size:20px">{point.district}</span><hr class="style-two">',
          pointFormat: '<span style="font-size:16px;">Rating: <b style="color:{point.color}">{point.rating}</b></span><br/><br/>',
          footerFormat: '<span style="font-size:12px">Click State for District Data</span><br/>'
        },
        series: [{
          animation: true,
          data: data,
          mapData: Highcharts.maps['maps/us-115-congress'],
          joinBy: 'hc-key',
          states: {hover: {color: '#BADA55'}},
          point: {events: {click: pointClick}},
          dataLabels: {enabled: false},
          cursor: 'pointer'
        }]
      };
      $.each(columns[0], function(i, key) {
        data.push({
          'hc-key': key,
          value: parseFloat(columns[1][i]),
          district: columns[2][i],
          incumbent: columns[3][i],
          incumbentVote: columns[4][i],
          challengerVote: columns[5][i],
          trump: columns[6][i],
          clinton: columns[7][i],
          obama: columns[8][i],
          romney: columns[9][i],
          row: i
        });
      });
      // Initiate the chart
      window.chart = new Highcharts.Map(options);
    }
  });
});
</code>```

Here's the jsfiddle link: https://jsfiddle.net/Peoples_Pundit/fz37sar7/

答:
I honestly don't know exactly what I changed, but I tried one last time after adding data via the manual var = [] method.

We always add data to maps, charts and tables from Google Spreadsheets and it would have taken us forever to manually add.

I did replace "code" with "key" defined all data into their own variables. You'll notice a lot of other features, but it's the same project as above.

Here's the new updated code (Note: You need highcharts-data.js for method and highcharts-more.js for the gauge):

```<code>jQuery(document).ready(function($) {
  Highcharts.data({
    //https://docs.google.com/spreadsheets/d/1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM/pubhtm
    googleSpreadsheetKey: '1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM',
    // custom handler when the spreadsheet is parsed
    parsed: function(columns) {
      // Read the columns into the data array
      var data = [];
      var change = {
        '-100': 'Dem',
        '-75': 'Likely',
        '-50': 'Leans',
        '-25': 'Slightly',
        '0': 'Toss',
        '25': 'Slightly',
        '50': 'Leans',
        '75': 'Likely',
        '100': 'GOP'
      };
      // Create the chart
      function pointClick() {
        // Holds var for each row, assign to = this.options row = this.options.row,
        var
          value = this.value,
          district = this.district,
          incumbent = this.incumbent,
          democratVote2016 = this.democratVote2016,
          republicanVote2016 = this.republicanVote2016,
          democratVote2018 = this.democratVote2018,
          republicanVote2018 = this.republicanVote2018,
          trump = this.trump,
          clinton = this.clinton,
          obama = this.obama,
          romney = this.romney,
          rating = this.rating,
          $div = $('<div></div>')
          .dialog({
            title: function() {
              $(this).closest("span.ui-dialog-title")
                .html('<h2 class="state-text">' + district + '</h2>');
            },
            open: function() {
              $(this).closest(".ui-dialog")
                .find(".ui-button-text-only")
                .removeClass(".ui-button-text-only")
                .addClass("ui-button-icon-only")
                .html("<span class='ui-button-icon ui-icon ui-icon-closethick'></span>");
            },
            width: 740,
            height: 740
          });
        window.chart = new Highcharts.Chart($div[0], {
          credits: {
            href: 'https://www.peoplespunditdaily.com/',
            text: 'People‘s Pundit Daily'
          },
          title: {
            text: 'Election Projection Data'
          },
          subtitle: {
            text: ''
          },
          tooltip: {
            useHTML: true,
            valueSuffix: '%',
            headerFormat: '<span style="font-size:12px">{series.name}</span><hr class="style-two">',
            pointFormat: '<span style="color:{point.color}">\u25CF</span> {point.name}: <b>{point.y}</b><br/>'
          },
          plotOptions: {
            pie: {
              dataLabels: {
                enabled: true,
                distance: 10,
                useHTML: true,
                style: {
                  fontWeight: 'bold',
                  color: 'black'
                }
              },
              startAngle: -90,
              endAngle: 90,
              center: ['50%', '75%']
            },
            gauge: {
              dataLabels: {
                enabled: true,
                useHTML: true,
                format: '{point.name}'
              },
              tooltip: {
                pointFormat: '<span style="color:{point.color}">\u25CF</span> {point.name}: <b>' + rating + '</b><br/>'
              },
              dial: {
                radius: '110%',
                backgroundColor: "{this.color}"
              }
            }
          },
          yAxis: {
            min: -100,
            max: 100,
            minorTickLength: 10,
            tickLength: 20,
            cursor: 'pointer',
            labels: {
              enable: true,
              useHTML: true,
              align: 'center',
              reserveSpace: false,
              rotation: 'auto',
              formatter: function() {
                var value = change[this.value];
                return value !== 'undefined' ? value : this.value;
              }
            },
            plotBands: [{
              from: -100,
              to: -75,
              color: '#006aab'
            }, {
              from: -75,
              to: -50,
              color: '#6193c7'
            }, {
              from: -50,
              to: -25,
              color: '#9cc0e3'
            }, {
              from: -25,
              to: -10,
              color: '#ceeafd'
            }, {
              from: -10,
              to: 10,
              color: '#C39BD3'
            }, {
              from: 10,
              to: 25,
              color: '#fbd0d0'
            }, {
              from: 25,
              to: 50,
              color: '#e99d98'
            }, {
              from: 50,
              to: 75,
              color: '#cf635d'
            }, {
              from: 75,
              to: 100,
              color: '#b02029'
            }]
          },
          pane: {
            startAngle: -90,
            endAngle: 90,
            center: ['50%', '90%'],
            size: 400,
            background: {
              backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
              innerRadius: '60%',
              outerRadius: '100%',
              shape: 'arc'
            }
          },
          series: [{
            type: 'pie',
            name: '2016 House Results',
            innerSize: '50%',
            data: [{
              name: 'Democrat Vote',
              color: '#006aab',
              y: parseFloat([democratVote2016], 10)
            }, {
              name: 'Republican Vote',
              color: '#b02029',
              y: parseFloat([republicanVote2016], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['25%', '20%'],
            size: 150
          }, {
            type: 'pie',
            name: '2014 House Results',
            innerSize: '50%',
            data: [{
              name: 'Democrat Vote',
              color: '#006aab',
              y: parseFloat([democratVote2018], 10)
            }, {
              name: 'Republican Vote',
              color: '#b02029',
              y: parseFloat([republicanVote2018], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['75%', '20%'],
            size: 150
          }, {
            type: 'pie',
            name: '2016 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Trump Vote',
              color: '#b02029',
              y: parseFloat([trump], 10)
            }, {
              name: 'Clinton Vote',
              color: '#006aab',
              y: parseFloat([clinton], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['25%', '45%'],
            size: 150
          }, {
            type: 'pie',
            name: '2012 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Obama Vote',
              color: '#006aab',
              y: parseFloat([obama], 10)
            }, {
              name: 'Romney Vote',
              color: '#b02029',
              y: parseFloat([romney], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['75%', '45%'],
            size: 150
          }, {
            type: 'gauge',
            name: 'Election Projection',
            data: [{
              name: 'Rating',
              y: parseFloat([value], 10)
            }],
            showInLegend: false
          }]
        });
      }
      options = {
        chart: {
          renderTo: 'container',
          backgroundColor: null
        },
        credits: {
          enabled: false
        },
        title: {
          style: {
            textShadow: '0 0.032em 0 #999, 0px 0.15em 0.11em rgba(0,0,0,0.15), 0px 0.25em 0.021em rgba(0,0,0,0.1), 0px 0.32em 0.32em rgba(0,0,0,0.1)',
            color: '#020202'
          },
          text: '2016 House of Representatives Battleground District Map'
        },
        subtitle: {
          style: {
            color: '#1d1c1d'
          },
          text: 'Source: PPD Election Projection Model'
        },
        legend: {
          layout: 'vertical',
          align: 'right',
          navigation: {
            enabled: true
          },
          verticalAlign: 'bottom'
        },
        mapNavigation: {
          enabled: true
        },
        colorAxis: {
          dataClasses: [{
            from: -100,
            to: -75,
            color: '#006aab',
            name: 'Democrat'
          }, {
            from: -75,
            to: -50,
            color: '#6193c7',
            name: 'Likely Democrat'
          }, {
            from: -50,
            to: -25,
            color: '#9cc0e3',
            name: 'Leans Democrat'
          }, {
            from: -25,
            to: -10,
            color: '#ceeafd',
            name: 'Slightly Democrat'
          }, {
            from: -10,
            to: 10,
            color: '#C39BD3',
            name: 'Battleground'
          }, {
            from: 10,
            to: 25,
            color: '#fbd0d0',
            name: 'Slightly Republican'
          }, {
            from: 25,
            to: 50,
            color: '#e99d98',
            name: 'Leans Republican'
          }, {
            from: 50,
            to: 75,
            color: '#cf635d',
            name: 'Likely Republican'
          }, {
            from: 75,
            to: 100,
            color: '#b02029',
            name: 'Republican'
          }]
        },
        tooltip: {
          useHTML: true,
          borderWidth: 2,
          backgroundColor: {
            linearGradient: [0, 0, 0, 60],
            stops: [
              [0, '#F6F5F4'],
              [1, '#FFFFFF']
            ]
          },
          headerFormat: '<span style="font-size:16px;"><b></b></span><hr class="style-two">',
          pointFormat: '<span style="font-size:12px;"><b>District: {point.district}</b><br/>Incumbent: {point.incumbent}<br/>Rating: <b style="color:{point.color}">{point.rating}</b></span><br/><br/>',
          footerFormat: '<span style="font-size:10px">Click State for District Data</span><br/>'
        },
        series: [{
          animation: true,
          data: data,
          mapData: Highcharts.maps['maps/us-115-congress'],
          joinBy: 'hc-key',
          name: 'PPD Election Projection',
          states: {
            hover: {
              color: null,
              brightness: 0,
              borderColor: '#1d1c1d',
              borderWidth: 2
            }
          },
          point: {
            events: {
              click: pointClick
            }
          },
          cursor: 'pointer',
          dataLabels: {
            enabled: false,
            format: '{point.name}'
          }
        }]
      };
      $.each(columns[0], function(i, key) {
        data.push({
          'hc-key': key,
          value: columns[1][i],
          district: columns[2][i],
          incumbent: columns[3][i],
          democratVote2016: columns[4][i],
          republicanVote2016: columns[5][i],
          democratVote2018: columns[6][i],
          republicanVote2018: columns[7][i],
          trump: columns[8][i],
          clinton: columns[9][i],
          obama: columns[10][i],
          romney: columns[11][i],
          rating: columns[12][i],
          row: i
        });
      });
      // Initiate the chart
      window.chart = new Highcharts.Map(options);
    }
  });
});
</code>```

And viola! Not sure if it's faster to define and place all those variables above again, or to just pull them using:

```<code>y: parseFloat(columns[15][row], 10)
</code>```

But it works and looks great.

Body:
I cannot figure out for the life of me why the hc-key for congressional districts cannot or is not getting associated correctly. I've tried just about every variation of the Highmaps and Highcharts joinBy that I can. I've also looked at every answer on Stack.

We've had no problem using spreadsheets for states, but this just isn't working out for us.

I'll include the fiddle link, but here's the code. I'm even leaving in commented out code just so you can see what attempts I've made that haven't worked out for me. Also, we have to tweak the districts provided by Highmaps to update them so consider the paths if you try to duplicate it.

Any help would be greatly appreciated!

jQuery(document).ready(function($) {
  Highcharts.data({
    // https://docs.google.com/spreadsheets/d/1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM/pubhtml
    googleSpreadsheetKey: '1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM',
    // custom handler when the spreadsheet is parsed
    parsed: function(columns) {
      // Read the columns into the data array
      var data = [];
      function pointClick() {
        var row = this.options.row,
        district = this.district,
          incumbent = this.incumbent,
          $div = $('

')
          .dialog({
            title: function() {
              $(this).closest("span.ui-dialog-title")
                .html('
' + district + ' ' + incumbent + '
');
            },
            open: function() {
              $(this).closest(".ui-dialog")
                .find(".ui-button-text-only")
                .removeClass(".ui-button-text-only")
                .addClass("ui-button-icon-only")
                .html("");
            },
            width: 740,
            height: 740
          });
        window.chart = new Highcharts.Chart($div[0], {
          credits: {
            href: 'https://www.peoplespunditdaily.com/',
            text: 'People‘s Pundit Daily'
          },
          title: {
            text: 'Election Projection Data'
          },
          subtitle: {
            text: 'Recent Election Results'
          },
          /*tooltip: {
            useHTML: true,
            headerFormat: '{series.name}
',
            pointFormat: '{point.name}: {point.percentage:.1f}% to {point.challengerVote}'
          },*/
          plotOptions: {
            pie: {
              dataLabels: {
                enabled: true,
                distance: 10,
                style: {
                  fontWeight: 'bold',
                  color: 'black'
                }
              },
              startAngle: -90,
              endAngle: 90,
              center: ['50%', '75%']
            }
          },
          series: [{
            type: 'pie',
            name: '2016 House Results',
            innerSize: '50%',
            data: [{
              name: 'Incumbent Vote',
              color: '#006aab',
              y: parseFloat(columns[incumbentVote][row], 10)
            }, {
              name: 'Challenger Vote',
              color: '#b02029',
              y: parseFloat(columns[challengerVote][row], 10)
            }],
            dataLabels: {
              enabled: true,
            },
            cursor: 'pointer',
            showInLegend: false,
            center: [160, 100],
            size: 120
          }, {
            type: 'pie',
            name: '2016 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Trump Vote Share',
              color: '#b02029',
              y: parseFloat(columns[trump][row], 10)
            }, {
              name: 'Clinton Vote Share',
              color: '#006aab',
              y: parseFloat(columns[clinton][row], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: [500, 100],
            size: 120
          }, {
            type: 'pie',
            name: '2012 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Obama Vote Share',
              color: '#006aab',
              y: parseFloat(columns[obama][row], 10)
            }, {
              name: 'Romney Vote Share',
              color: '#b02029',
              y: parseFloat(columns[romney][row], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: [160, 300],
            size: 120
          }]
        });
      }
      options = {
        chart: {
          renderTo: 'container',
          backgroundColor: null
        },
        credits: {
          enabled: false
        },
        title: {
          style: {
            textShadow: '0 0.032em 0 #999, 0px 0.15em 0.11em rgba(0,0,0,0.15), 0px 0.25em 0.021em rgba(0,0,0,0.1), 0px 0.32em 0.32em rgba(0,0,0,0.1)',
            color: '#020202'
          },
          text: '2016 House of Representatives Battleground District Map'
        },
        subtitle: {
          style: {
            color: '#1d1c1d'
          },
          text: 'Source: PPD Election Projection Model'
        },
        legend: {
          layout: 'vertical',
          align: 'right',
          navigation: {
            enabled: true
          },
          verticalAlign: 'bottom'
        },
        mapNavigation: {
          enabled: false
        },
        colorAxis: {
          dataClasses: [{
            from: -100,
            to: -75,
            color: '#006aab',
            name: 'Democrat'
          }, {
            from: -75,
            to: -50,
            color: '#6193c7',
            name: 'Likely Democrat'
          }, {
            from: -50,
            to: -25,
            color: '#9cc0e3',
            name: 'Leans Democrat'
          }, {
            from: -25,
            to: -10,
            color: '#ceeafd',
            name: 'Trump District Leans Democrat'
          }, {
            from: -10,
            to: 10,
            color: '#C39BD3',
            name: 'Battleground'
          }, {
            from: 10,
            to: 25,
            color: '#fbd0d0',
            name: 'Clinton District Leans Republican'
          }, {
            from: 25,
            to: 50,
            color: '#e99d98',
            name: 'Leans Republican'
          }, {
            from: 50,
            to: 75,
            color: '#cf635d',
            name: 'Likely Republican'
          }, {
            from: 75,
            to: 100,
            color: '#b02029',
            name: 'Republican'
          }]
        },
        tooltip: {
          useHTML: true,
          borderWidth: 2,
          backgroundColor: {
            linearGradient: [0, 0, 0, 60],
            stops: [
              [0, '#F6F5F4'],
              [1, '#FFFFFF']
            ]
          },
          headerFormat: '{point.district}
',
          pointFormat: 'Rating: {point.rating}

',
          footerFormat: 'Click State for District Data
'
        },
        series: [{
          animation: true,
          data: data,
          mapData: Highcharts.maps['maps/us-115-congress'],
          joinBy: 'hc-key',
          states: {hover: {color: '#BADA55'}},
          point: {events: {click: pointClick}},
          dataLabels: {enabled: false},
          cursor: 'pointer'
        }]
      };
      $.each(columns[0], function(i, key) {
        data.push({
          'hc-key': key,
          value: parseFloat(columns[1][i]),
          district: columns[2][i],
          incumbent: columns[3][i],
          incumbentVote: columns[4][i],
          challengerVote: columns[5][i],
          trump: columns[6][i],
          clinton: columns[7][i],
          obama: columns[8][i],
          romney: columns[9][i],
          row: i
        });
      });
      // Initiate the chart
      window.chart = new Highcharts.Map(options);
    }
  });
});

Here's the jsfiddle link: https://jsfiddle.net/Peoples_Pundit/fz37sar7/

Body:
I honestly don't know exactly what I changed, but I tried one last time after adding data via the manual var = [] method.

We always add data to maps, charts and tables from Google Spreadsheets and it would have taken us forever to manually add.

I did replace "code" with "key" defined all data into their own variables. You'll notice a lot of other features, but it's the same project as above.

Here's the new updated code (Note: You need highcharts-data.js for method and highcharts-more.js for the gauge):

jQuery(document).ready(function($) {
  Highcharts.data({
    //https://docs.google.com/spreadsheets/d/1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM/pubhtm
    googleSpreadsheetKey: '1Z0oRIsToDT0MnlP2pfBvSN3fd-lW8nIzxTpq_fdxPDM',
    // custom handler when the spreadsheet is parsed
    parsed: function(columns) {
      // Read the columns into the data array
      var data = [];
      var change = {
        '-100': 'Dem',
        '-75': 'Likely',
        '-50': 'Leans',
        '-25': 'Slightly',
        '0': 'Toss',
        '25': 'Slightly',
        '50': 'Leans',
        '75': 'Likely',
        '100': 'GOP'
      };
      // Create the chart
      function pointClick() {
        // Holds var for each row, assign to = this.options row = this.options.row,
        var
          value = this.value,
          district = this.district,
          incumbent = this.incumbent,
          democratVote2016 = this.democratVote2016,
          republicanVote2016 = this.republicanVote2016,
          democratVote2018 = this.democratVote2018,
          republicanVote2018 = this.republicanVote2018,
          trump = this.trump,
          clinton = this.clinton,
          obama = this.obama,
          romney = this.romney,
          rating = this.rating,
          $div = $('<div></div>')
          .dialog({
            title: function() {
              $(this).closest("span.ui-dialog-title")
                .html('<h2 class="state-text">' + district + '</h2>');
            },
            open: function() {
              $(this).closest(".ui-dialog")
                .find(".ui-button-text-only")
                .removeClass(".ui-button-text-only")
                .addClass("ui-button-icon-only")
                .html("<span class='ui-button-icon ui-icon ui-icon-closethick'></span>");
            },
            width: 740,
            height: 740
          });
        window.chart = new Highcharts.Chart($div[0], {
          credits: {
            href: 'https://www.peoplespunditdaily.com/',
            text: 'People‘s Pundit Daily'
          },
          title: {
            text: 'Election Projection Data'
          },
          subtitle: {
            text: ''
          },
          tooltip: {
            useHTML: true,
            valueSuffix: '%',
            headerFormat: '<span style="font-size:12px">{series.name}</span><hr class="style-two">',
            pointFormat: '<span style="color:{point.color}">\u25CF</span> {point.name}: <b>{point.y}</b><br/>'
          },
          plotOptions: {
            pie: {
              dataLabels: {
                enabled: true,
                distance: 10,
                useHTML: true,
                style: {
                  fontWeight: 'bold',
                  color: 'black'
                }
              },
              startAngle: -90,
              endAngle: 90,
              center: ['50%', '75%']
            },
            gauge: {
              dataLabels: {
                enabled: true,
                useHTML: true,
                format: '{point.name}'
              },
              tooltip: {
                pointFormat: '<span style="color:{point.color}">\u25CF</span> {point.name}: <b>' + rating + '</b><br/>'
              },
              dial: {
                radius: '110%',
                backgroundColor: "{this.color}"
              }
            }
          },
          yAxis: {
            min: -100,
            max: 100,
            minorTickLength: 10,
            tickLength: 20,
            cursor: 'pointer',
            labels: {
              enable: true,
              useHTML: true,
              align: 'center',
              reserveSpace: false,
              rotation: 'auto',
              formatter: function() {
                var value = change[this.value];
                return value !== 'undefined' ? value : this.value;
              }
            },
            plotBands: [{
              from: -100,
              to: -75,
              color: '#006aab'
            }, {
              from: -75,
              to: -50,
              color: '#6193c7'
            }, {
              from: -50,
              to: -25,
              color: '#9cc0e3'
            }, {
              from: -25,
              to: -10,
              color: '#ceeafd'
            }, {
              from: -10,
              to: 10,
              color: '#C39BD3'
            }, {
              from: 10,
              to: 25,
              color: '#fbd0d0'
            }, {
              from: 25,
              to: 50,
              color: '#e99d98'
            }, {
              from: 50,
              to: 75,
              color: '#cf635d'
            }, {
              from: 75,
              to: 100,
              color: '#b02029'
            }]
          },
          pane: {
            startAngle: -90,
            endAngle: 90,
            center: ['50%', '90%'],
            size: 400,
            background: {
              backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
              innerRadius: '60%',
              outerRadius: '100%',
              shape: 'arc'
            }
          },
          series: [{
            type: 'pie',
            name: '2016 House Results',
            innerSize: '50%',
            data: [{
              name: 'Democrat Vote',
              color: '#006aab',
              y: parseFloat([democratVote2016], 10)
            }, {
              name: 'Republican Vote',
              color: '#b02029',
              y: parseFloat([republicanVote2016], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['25%', '20%'],
            size: 150
          }, {
            type: 'pie',
            name: '2014 House Results',
            innerSize: '50%',
            data: [{
              name: 'Democrat Vote',
              color: '#006aab',
              y: parseFloat([democratVote2018], 10)
            }, {
              name: 'Republican Vote',
              color: '#b02029',
              y: parseFloat([republicanVote2018], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['75%', '20%'],
            size: 150
          }, {
            type: 'pie',
            name: '2016 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Trump Vote',
              color: '#b02029',
              y: parseFloat([trump], 10)
            }, {
              name: 'Clinton Vote',
              color: '#006aab',
              y: parseFloat([clinton], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['25%', '45%'],
            size: 150
          }, {
            type: 'pie',
            name: '2012 Presidential Vote',
            innerSize: '50%',
            data: [{
              name: 'Obama Vote',
              color: '#006aab',
              y: parseFloat([obama], 10)
            }, {
              name: 'Romney Vote',
              color: '#b02029',
              y: parseFloat([romney], 10)
            }],
            cursor: 'pointer',
            showInLegend: false,
            center: ['75%', '45%'],
            size: 150
          }, {
            type: 'gauge',
            name: 'Election Projection',
            data: [{
              name: 'Rating',
              y: parseFloat([value], 10)
            }],
            showInLegend: false
          }]
        });
      }
      options = {
        chart: {
          renderTo: 'container',
          backgroundColor: null
        },
        credits: {
          enabled: false
        },
        title: {
          style: {
            textShadow: '0 0.032em 0 #999, 0px 0.15em 0.11em rgba(0,0,0,0.15), 0px 0.25em 0.021em rgba(0,0,0,0.1), 0px 0.32em 0.32em rgba(0,0,0,0.1)',
            color: '#020202'
          },
          text: '2016 House of Representatives Battleground District Map'
        },
        subtitle: {
          style: {
            color: '#1d1c1d'
          },
          text: 'Source: PPD Election Projection Model'
        },
        legend: {
          layout: 'vertical',
          align: 'right',
          navigation: {
            enabled: true
          },
          verticalAlign: 'bottom'
        },
        mapNavigation: {
          enabled: true
        },
        colorAxis: {
          dataClasses: [{
            from: -100,
            to: -75,
            color: '#006aab',
            name: 'Democrat'
          }, {
            from: -75,
            to: -50,
            color: '#6193c7',
            name: 'Likely Democrat'
          }, {
            from: -50,
            to: -25,
            color: '#9cc0e3',
            name: 'Leans Democrat'
          }, {
            from: -25,
            to: -10,
            color: '#ceeafd',
            name: 'Slightly Democrat'
          }, {
            from: -10,
            to: 10,
            color: '#C39BD3',
            name: 'Battleground'
          }, {
            from: 10,
            to: 25,
            color: '#fbd0d0',
            name: 'Slightly Republican'
          }, {
            from: 25,
            to: 50,
            color: '#e99d98',
            name: 'Leans Republican'
          }, {
            from: 50,
            to: 75,
            color: '#cf635d',
            name: 'Likely Republican'
          }, {
            from: 75,
            to: 100,
            color: '#b02029',
            name: 'Republican'
          }]
        },
        tooltip: {
          useHTML: true,
          borderWidth: 2,
          backgroundColor: {
            linearGradient: [0, 0, 0, 60],
            stops: [
              [0, '#F6F5F4'],
              [1, '#FFFFFF']
            ]
          },
          headerFormat: '<span style="font-size:16px;"><b></b></span><hr class="style-two">',
          pointFormat: '<span style="font-size:12px;"><b>District: {point.district}</b><br/>Incumbent: {point.incumbent}<br/>Rating: <b style="color:{point.color}">{point.rating}</b></span><br/><br/>',
          footerFormat: '<span style="font-size:10px">Click State for District Data</span><br/>'
        },
        series: [{
          animation: true,
          data: data,
          mapData: Highcharts.maps['maps/us-115-congress'],
          joinBy: 'hc-key',
          name: 'PPD Election Projection',
          states: {
            hover: {
              color: null,
              brightness: 0,
              borderColor: '#1d1c1d',
              borderWidth: 2
            }
          },
          point: {
            events: {
              click: pointClick
            }
          },
          cursor: 'pointer',
          dataLabels: {
            enabled: false,
            format: '{point.name}'
          }
        }]
      };
      $.each(columns[0], function(i, key) {
        data.push({
          'hc-key': key,
          value: columns[1][i],
          district: columns[2][i],
          incumbent: columns[3][i],
          democratVote2016: columns[4][i],
          republicanVote2016: columns[5][i],
          democratVote2018: columns[6][i],
          republicanVote2018: columns[7][i],
          trump: columns[8][i],
          clinton: columns[9][i],
          obama: columns[10][i],
          romney: columns[11][i],
          rating: columns[12][i],
          row: i
        });
      });
      // Initiate the chart
      window.chart = new Highcharts.Map(options);
    }
  });
});

And viola! Not sure if it's faster to define and place all those variables above again, or to just pull them using:

y: parseFloat(columns[15][row], 10)

But it works and looks great.


问:
Objective-c Novice - Needs help with UIViews
Im new to iphone development and after lots of reading on it im still trying to figure out how UIViews operate properly. I have been playing about with it and i this is where i am at so far:

I have created a new xcode project using the view-based application. I have my MMAppViewController classes and i created a new UIViewController subclass called "Level1View".

There is a button titled "Level 1" that takes me to the "Level1View" viewController. In this viewController there is there is a "next" button, a "main menu" button (that returns to MMAppViewController) and there is a label, currently titled "Level 1".

My problem is that the code i have used to change the title of label does not work! Does anyone know why this is? Here is my code:

```<code>@class MMAppViewController;

@interface MMAppAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MMAppViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MMAppViewController *viewController;

@end
</code>```

and

```<code>@implementation MMAppViewController

-(IBAction)pushLevel1{

    Level1View *level1View = [[Level1View alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:level1View animated:YES];
}
...
</code>```

and

```<code>#import <UIKit/UIKit.h>

@interface Level1View : UIViewController {
    IBOutlet UILabel *labelTitle;

}
-(IBAction)pushBack;
-(IBAction)pushNext;
@end
</code>```

and

```<code> #import "Level1View.h"
    #import "MMAppViewController.h"

    @implementation Level1View

    -(IBAction)pushBack{

        MMAppViewController *MainView = [[MMAppViewController alloc] initWithNibName:nil bundle:nil];
        [self presentModalViewController:MainView animated:YES];

    }
    -(IBAction)pushNext{

        [labelTitle setText:(@"Thanks for playing :)")];

    }

    - (void)didReceiveMemoryWarning {
    ...
</code>```

Currently the app runs but the label wont change when i hit the "next" button. Can anyone help?

答:
Declare labelTitle as a property in your header file, and synthesize labelTitle in your .m - as long as labelTitle is hooked up through interface builder the rest of your code is fine.

```<code>.h
@property (nonatomic, retain) IBOutlet UILabel *labelTitle;

.m
@synthesize labelTitle;
</code>```

Then your setter call will work. (also, dot-notation works for synthesized properties so you may as well use it)

```<code>change
[labelTitle setText:(@"Thanks for playing :)")];
to
labelTitle.text = @"Thanks for playing :)";
</code>```

Synthesizing a property will create setter and getter methods at runtime. Read: The Objective-C Programming Language

ContentLicense: CC BY-SA 2.5

Body:
Im new to iphone development and after lots of reading on it im still trying to figure out how UIViews operate properly. I have been playing about with it and i this is where i am at so far:

I have created a new xcode project using the view-based application. I have my MMAppViewController classes and i created a new UIViewController subclass called "Level1View".

There is a button titled "Level 1" that takes me to the "Level1View" viewController. In this viewController there is there is a "next" button, a "main menu" button (that returns to MMAppViewController) and there is a label, currently titled "Level 1".

My problem is that the code i have used to change the title of label does not work! Does anyone know why this is? Here is my code:

@class MMAppViewController;

@interface MMAppAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MMAppViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MMAppViewController *viewController;

@end

and

@implementation MMAppViewController

-(IBAction)pushLevel1{

    Level1View *level1View = [[Level1View alloc] initWithNibName:nil bundle:nil];
    [self presentModalViewController:level1View animated:YES];
}
...

and

#import <UIKit/UIKit.h>

@interface Level1View : UIViewController {
    IBOutlet UILabel *labelTitle;

}
-(IBAction)pushBack;
-(IBAction)pushNext;
@end

and

 #import "Level1View.h"
    #import "MMAppViewController.h"

    @implementation Level1View

    -(IBAction)pushBack{

        MMAppViewController *MainView = [[MMAppViewController alloc] initWithNibName:nil bundle:nil];
        [self presentModalViewController:MainView animated:YES];

    }
    -(IBAction)pushNext{

        [labelTitle setText:(@"Thanks for playing :)")];

    }

    - (void)didReceiveMemoryWarning {
    ...

Currently the app runs but the label wont change when i hit the "next" button. Can anyone help?

Body:
Declare labelTitle as a property in your header file, and synthesize labelTitle in your .m - as long as labelTitle is hooked up through interface builder the rest of your code is fine.

.h
@property (nonatomic, retain) IBOutlet UILabel *labelTitle;

.m
@synthesize labelTitle;

Then your setter call will work. (also, dot-notation works for synthesized properties so you may as well use it)

change
[labelTitle setText:(@"Thanks for playing :)")];
to
labelTitle.text = @"Thanks for playing :)";

Synthesizing a property will create setter and getter methods at runtime. Read: The Objective-C Programming Language


问:
How to convert Json type with array to .net object?
I have JSON string:
// the coverage value is an array.

```<code>  string jsonData = @"{
""plans"":
[
{
""plan_code"":""UL500"",
    ""plan_name"":""Unlimited 500M"",
    ""days"":1,
    ""limit"":500,
    ""coverage"":
[
{
""country"":""SE"",
},
{
""country"":""BZ""
}
]
},
{
""plan_code"":""UL1GB"",
    ""plan_name"":""Unlimited 1GB"",
    ""days"":1,
    ""limit"":1024,
    ""coverage"":
[
{
""country"":""SG"",
},
{
""country"":""JP""
}
]
}
]
}
";
</code>```

and i'm parse by JsonConvert.DeserializeObject as sample code below:

```<code> try
    {
        var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
        HttpResponseMessage response = await client.PostAsync("", content);
        var result = await response.Content.ReadAsStringAsync();
        var tempRecords = JsonConvert.DeserializeObject<List<plan>>(result);
    }
</code>```

and then i'm get an error message:
    "Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[DAL.plan]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath 'plans', line 1, position 9."

please show me a right way for this issue.

答:
Here is the working code with the same JSON, from my console app:

```<code>public class Program
{
    static void Main(string[] args)
    {
        string jsonData = "{\"plans\":[{\"plan_code\":\"UL500\",\"plan_name\":\"Unlimited 500M\",\"days\":1,\"limit\":500,\"coverage\":[{\"country\":\"SE\"},{\"country\":\"BZ\"}]},{\"plan_code\":\"UL1GB\",\"plan_name\":\"Unlimited 1GB\",\"days\":1,\"limit\":1024,\"coverage\":[{\"country\":\"SG\"},{\"country\":\"JP\"}]}]}";

        var tempRecords = JsonConvert.DeserializeObject<RootObject>(jsonData);

    }
}

public class RootObject
{
    public List<plan> plans { get; set; }
}

public class plan
{
    public string plan_code { get; set; }
    public string plan_name { get; set; }
    public int days { get; set; }
    public int limit { get; set; }
    public IList<Country> coverage { get; set; }
}

public class Country
{
    public string country { get; set; }
}
</code>```

I have created C# classes that suits your JSON structure.
As a note, I have modified the JSON you provided, as it seems to be not in the correct format.

Body:
I have JSON string:
// the coverage value is an array.

  string jsonData = @"{
""plans"":
[
{
""plan_code"":""UL500"",
    ""plan_name"":""Unlimited 500M"",
    ""days"":1,
    ""limit"":500,
    ""coverage"":
[
{
""country"":""SE"",
},
{
""country"":""BZ""
}
]
},
{
""plan_code"":""UL1GB"",
    ""plan_name"":""Unlimited 1GB"",
    ""days"":1,
    ""limit"":1024,
    ""coverage"":
[
{
""country"":""SG"",
},
{
""country"":""JP""
}
]
}
]
}
";

and i'm parse by JsonConvert.DeserializeObject as sample code below:

 try
    {
        var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
        HttpResponseMessage response = await client.PostAsync("", content);
        var result = await response.Content.ReadAsStringAsync();
        var tempRecords = JsonConvert.DeserializeObject<List<plan>>(result);
    }

and then i'm get an error message:
    "Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[DAL.plan]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath 'plans', line 1, position 9."

please show me a right way for this issue.

Body:
Here is the working code with the same JSON, from my console app:

public class Program
{
    static void Main(string[] args)
    {
        string jsonData = "{\"plans\":[{\"plan_code\":\"UL500\",\"plan_name\":\"Unlimited 500M\",\"days\":1,\"limit\":500,\"coverage\":[{\"country\":\"SE\"},{\"country\":\"BZ\"}]},{\"plan_code\":\"UL1GB\",\"plan_name\":\"Unlimited 1GB\",\"days\":1,\"limit\":1024,\"coverage\":[{\"country\":\"SG\"},{\"country\":\"JP\"}]}]}";

        var tempRecords = JsonConvert.DeserializeObject<RootObject>(jsonData);

    }
}

public class RootObject
{
    public List<plan> plans { get; set; }
}

public class plan
{
    public string plan_code { get; set; }
    public string plan_name { get; set; }
    public int days { get; set; }
    public int limit { get; set; }
    public IList<Country> coverage { get; set; }
}

public class Country
{
    public string country { get; set; }
}

I have created C# classes that suits your JSON structure.
As a note, I have modified the JSON you provided, as it seems to be not in the correct format.


问:
To Do List runtime issue
I tried to create a simple To-Do List program. It asks how many items you want in your list, it asks for each item, and it asks you if you want to display the items. However, I'm having a runtime error. When the program asks for the first item, it doesn't allow me to enter what my first list item is. When it lists my items in numerical order, the first item on the list (which I couldn't input text for, it skipped past it after displaying the text) appears twice. So, if I had 3 items on the list, here's what it would display:

```<code>1.
1.
2. (Second item)
3. (Third item)
</code>```

I've combed through the code, redone parts, and I can't find the issue. Here is my code:

```<code>import java.util.Scanner;

/*
This is a program that will
help you create a To-Do List
*/

public class ToDoList
{
public static void main(String[] args)
{

    int numOfItems = -1, answer;
    Scanner keyboard = new Scanner(System.in);

    System.out.println("\n\nHello!\nThis is a program that will " +
                        "help you create a To-Do List.");

    while (numOfItems < 0)
    {
        System.out.println("\nHow many items do you want to add?");
        if (keyboard.hasNextInt())
            numOfItems = keyboard.nextInt();
    }

    String[] itemsArray = new String[numOfItems];

    for (int increasingNum = 0; numOfItems > increasingNum; increasingNum++)
    {
            System.out.println("\nPlease enter item number: " + (increasingNum + 1));
            itemsArray[increasingNum] = keyboard.nextLine();
    }

    System.out.println("\nCongratulations! You have successfully created a To-Do List." +
                        "\nWould you like to view the list now?" +
                        "\n\nEnter:\n\t\"1\" for Yes\n\t\"2\" for No");
    answer = keyboard.nextInt();

    if (answer == 1)
    {
        for (int secondIncreasingNum = 0; numOfItems > secondIncreasingNum; secondIncreasingNum++)
        {
            System.out.println((secondIncreasingNum + 1) + ". " + itemsArray[secondIncreasingNum]);
        }
    }

    System.exit(0);

}
}
</code>```

EDIT: I've fixed the first problem when it asks you to enter item number one, but the error at the end still occurs. It now lists it like this:

(empty)
1.(item 1)
2.(item 2)
etc.

答:
There are bunch of problems with your code, before you get the keyboard input you need to check for keyboard.hasNextInt() also you need to initialize the answer variable.

```<code> public static void main(String[] args)
</code>```

{

```<code> int numOfItems = 0, answer = 0, number = 1, secondNumber = 1;
Scanner keyboard = new Scanner(System.in);

System.out.println("\n\nHello!\nThis is a program that will " +
                    "help you create a To-Do List.");

do
{
    System.out.println("\nHow many items do you want to add?");
    if(keyboard.hasNextInt())
    numOfItems = keyboard.nextInt();
}
while (numOfItems != -1 && numOfItems < 0);

String[] itemsArray = new String[numOfItems];

for (int increasingNum = 0; numOfItems > increasingNum; increasingNum++)
{
        System.out.println("\nPlease enter item number: " + number);
        itemsArray[increasingNum] = keyboard.nextLine();
        number++;
}

System.out.println("\nCongratulations! You have successfully created a To-Do List." +
                    "\nWould you like to view the list now?" +
                    "\n\nEnter:\n\t\"1\" for Yes\n\t\"2\" for No");
if(keyboard.hasNextInt())
    answer = keyboard.nextInt();

if (answer == 1)
{
    for (int secondIncreasingNum = 0; numOfItems > secondIncreasingNum; secondIncreasingNum++)
    {
        System.out.println(secondNumber + ". " + itemsArray[secondIncreasingNum]);
        secondNumber++;
    }
}

System.exit(0);
</code>```

}
}

Title: To Do List runtime issue

Body:
I tried to create a simple To-Do List program. It asks how many items you want in your list, it asks for each item, and it asks you if you want to display the items. However, I'm having a runtime error. When the program asks for the first item, it doesn't allow me to enter what my first list item is. When it lists my items in numerical order, the first item on the list (which I couldn't input text for, it skipped past it after displaying the text) appears twice. So, if I had 3 items on the list, here's what it would display:

1.
1.
2. (Second item)
3. (Third item)

I've combed through the code, redone parts, and I can't find the issue. Here is my code:

import java.util.Scanner;

/*
This is a program that will
help you create a To-Do List
*/

public class ToDoList
{
public static void main(String[] args)
{

    int numOfItems = -1, answer;
    Scanner keyboard = new Scanner(System.in);

    System.out.println("\n\nHello!\nThis is a program that will " +
                        "help you create a To-Do List.");

    while (numOfItems < 0)
    {
        System.out.println("\nHow many items do you want to add?");
        if (keyboard.hasNextInt())
            numOfItems = keyboard.nextInt();
    }

    String[] itemsArray = new String[numOfItems];

    for (int increasingNum = 0; numOfItems > increasingNum; increasingNum++)
    {
            System.out.println("\nPlease enter item number: " + (increasingNum + 1));
            itemsArray[increasingNum] = keyboard.nextLine();
    }

    System.out.println("\nCongratulations! You have successfully created a To-Do List." +
                        "\nWould you like to view the list now?" +
                        "\n\nEnter:\n\t\"1\" for Yes\n\t\"2\" for No");
    answer = keyboard.nextInt();

    if (answer == 1)
    {
        for (int secondIncreasingNum = 0; numOfItems > secondIncreasingNum; secondIncreasingNum++)
        {
            System.out.println((secondIncreasingNum + 1) + ". " + itemsArray[secondIncreasingNum]);
        }
    }

    System.exit(0);

}
}

EDIT: I've fixed the first problem when it asks you to enter item number one, but the error at the end still occurs. It now lists it like this:

(empty)
1.(item 1)
2.(item 2)
etc.

Body:
There are bunch of problems with your code, before you get the keyboard input you need to check for keyboard.hasNextInt() also you need to initialize the answer variable.

 public static void main(String[] args)

{

 int numOfItems = 0, answer = 0, number = 1, secondNumber = 1;
Scanner keyboard = new Scanner(System.in);

System.out.println("\n\nHello!\nThis is a program that will " +
                    "help you create a To-Do List.");

do
{
    System.out.println("\nHow many items do you want to add?");
    if(keyboard.hasNextInt())
    numOfItems = keyboard.nextInt();
}
while (numOfItems != -1 && numOfItems < 0);

String[] itemsArray = new String[numOfItems];

for (int increasingNum = 0; numOfItems > increasingNum; increasingNum++)
{
        System.out.println("\nPlease enter item number: " + number);
        itemsArray[increasingNum] = keyboard.nextLine();
        number++;
}

System.out.println("\nCongratulations! You have successfully created a To-Do List." +
                    "\nWould you like to view the list now?" +
                    "\n\nEnter:\n\t\"1\" for Yes\n\t\"2\" for No");
if(keyboard.hasNextInt())
    answer = keyboard.nextInt();

if (answer == 1)
{
    for (int secondIncreasingNum = 0; numOfItems > secondIncreasingNum; secondIncreasingNum++)
    {
        System.out.println(secondNumber + ". " + itemsArray[secondIncreasingNum]);
        secondNumber++;
    }
}

System.exit(0);

}
}


问:
Array representation
i wonder what is the difference of array representation between [] and (3) [Object,Object,Object] ?

i have array of objects like:

```<code>var array = [{id: 1, text: 'a'}, {id: 2, text: 'b'}, {id: 3, text: 'c'}];
</code>```

when i tried to console.log(array) at some line within my codes, sometime it printed as [] and sometime as (3) [Object,Object,Object]. the [] is not empty, though, when i expanded it on browser's console, both contain same values (3 objects).

in my case, when i'm using var array as data for my select2 like this:

```<code>$('#elems').select2({
      data: array
});
</code>```

if, when i console.log(array) and it shows as (3) [Object, Object, Object], the select2 gets the data, and the option would be a,b,c. but, when it shows as [] select2 couldn't read the objects, thus, the option would be empty.

i wonder if select2 reads [] as empty, although on browser's console [] is expandable and contains value. like this:

can anyone explain about this?

答:
It's a timing issue. console.log runs before the items have been added. Run this snippet for an example. You'd have to hit the timing just right. Most likely a race condition.

var array = [{id: 1, text: 'a'}, {id: 2, text: 'b'}, {id: 3, text: 'c'}];
console.log(array);

var array = [];
setTimeout(function(){
  array.push({id: 1, text: 'a'}, {id: 2, text: 'b'}, {id: 3, text: 'c'});
  }, 1000);
console.log(array);```

Title: Array representation

Body:
i wonder what is the difference of array representation between [] and (3) [Object,Object,Object] ?

i have array of objects like:

var array = [{id: 1, text: 'a'}, {id: 2, text: 'b'}, {id: 3, text: 'c'}];

when i tried to console.log(array) at some line within my codes, sometime it printed as [] and sometime as (3) [Object,Object,Object]. the [] is not empty, though, when i expanded it on browser's console, both contain same values (3 objects).

in my case, when i'm using var array as data for my select2 like this:

$('#elems').select2({
      data: array
});

if, when i console.log(array) and it shows as (3) [Object, Object, Object], the select2 gets the data, and the option would be a,b,c. but, when it shows as [] select2 couldn't read the objects, thus, the option would be empty.

i wonder if select2 reads [] as empty, although on browser's console [] is expandable and contains value. like this:

can anyone explain about this?


问:
How to find most popular elements in multiple sets
I have a map structured as follows

Map<String, Set<String> myMapOfSets = new HashSet<>():

This map is of size 400. And each of these 400 sets can be of size anywhere between 100 to 10000 elements. Many elements in these sets are repeating. I am looking to find say top 10 elements which are most popular in these 400 sets. How to implement that? Thanks for any help.

答:
If this is homework related, here is some tips:

Assuming the map can be treated as a set of sets, and that the string keys arn't related.

```<code>Create a new map called scores, store strings and ints
Iterate over the sets
   Iterate over the values of a set
     get the value of the string from scores defaulting to 0, and add 1.
</code>```

You now have a map of occurrences,

```<code>create a list of mapentries of length 10, keep it sorted.
Loop over the map
   if the current value is higher then the min value in the list, replace the lowest value, and keep track of the new minimumscore.
</code>```

Body:
If this is homework related, here is some tips:

Assuming the map can be treated as a set of sets, and that the string keys arn't related.

Create a new map called scores, store strings and ints
Iterate over the sets
   Iterate over the values of a set
     get the value of the string from scores defaulting to 0, and add 1.

You now have a map of occurrences,

create a list of mapentries of length 10, keep it sorted.
Loop over the map
   if the current value is higher then the min value in the list, replace the lowest value, and keep track of the new minimumscore.


问:
Make a HMTL  hyperlink not appear as a hyperlink
I'm making a website (for schoolwork) using a combination of php, html and css. I'm currently working on the initial design stages of my site and as I'm inexperienced at html / css, I am going slowly through tutorials trying to learn.

Including the hyperlink my banner looks like:

Not including the hyperlink my banner looks like:

I want to have the functionality of the link, but the visual design effect of without the link.

The necessary code is:

```<code><html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <center>
    <div id = "indexBackgroundOne"><h2 style="font-family:verdana"> Q U E S T S ®</h2></div>
    </center>
</html>
</code>```

Thanks!

答:
try this for the desired effect:

.no-style {
    text-decoration: none;
    color: black;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><center>
  <div id = "indexBackgroundOne">
      <h2 style="font-family:verdana">
          Q U E S T S ®
      </h2>
  </div>
</center></code>```

or if you want inline styles:

             Q U E S T S ®

```

Title: Make a HMTL <a href> hyperlink not appear as a hyperlink

Body:
I'm making a website (for schoolwork) using a combination of php, html and css. I'm currently working on the initial design stages of my site and as I'm inexperienced at html / css, I am going slowly through tutorials trying to learn.

Including the hyperlink my banner looks like:

Not including the hyperlink my banner looks like:

I want to have the functionality of the link, but the visual design effect of without the link.

The necessary code is:

        <link rel="stylesheet" type="text/css" href="style.css">

 Q U E S T S ®

Thanks!

Body:
try this for the desired effect:

.no-style {
    text-decoration: none;
    color: black;
}

<center>
  <div id = "indexBackgroundOne">
      <h2 style="font-family:verdana">
          <a href="" class="no-style">Q U E S T S &reg;</a>
      </h2>
  </div>
</center>

or if you want inline styles:

<center>
    <div id = "indexBackgroundOne">
        <h2 style="font-family:verdana;">
            <a href="" style="text-decoration:none;color:black;"> Q U E S T S &reg;
            </a>
        </h2>
    </div>
</center>


问:
Find the missing integer in an arithmetic progression from a list in python
My code below return the correct missing integers for arrays of size 10, 100, 1000, 10000, and 100000, but then returns the error "Max Buffer reached: Too much information has been written to stdout. Process exited prematurely with a SIGKILL signal. "

This is preventing me from completing the Codewars exercise. Am I doing anything wrong? somehow there is a right way to complete this exercise, and I thought I had it

```<code>def find_missing(sequence):
    s1 = []
    a = sequence[1] - sequence[0]
    c = sequence[0]
    s1.append(c)
    for x in range(0,len(sequence)):
        c += a
        s1.append(c)

    d = set(s1)
    e = set(sequence)
    print(d)
    print(e)
    f = [i for i in d if i not in e]

    return f[0]
</code>```

答:
If I understand the question correctly wouldn't itertools.count() with zip() solve this problem, e.g.:

```<code>import itertools as it

def find_missing(sequence):
    for x, y in zip(it.count(sequence[0], sequence[1]-sequence[0]), sequence):
        if x != y:
            return x
</code>```

Note: Diagnostic print()s are probably your issue.

Body:
My code below return the correct missing integers for arrays of size 10, 100, 1000, 10000, and 100000, but then returns the error "Max Buffer reached: Too much information has been written to stdout. Process exited prematurely with a SIGKILL signal. "

This is preventing me from completing the Codewars exercise. Am I doing anything wrong? somehow there is a right way to complete this exercise, and I thought I had it

def find_missing(sequence):
    s1 = []
    a = sequence[1] - sequence[0]
    c = sequence[0]
    s1.append(c)
    for x in range(0,len(sequence)):
        c += a
        s1.append(c)

    d = set(s1)
    e = set(sequence)
    print(d)
    print(e)
    f = [i for i in d if i not in e]

    return f[0]

Body:
If I understand the question correctly wouldn't itertools.count() with zip() solve this problem, e.g.:

import itertools as it

def find_missing(sequence):
    for x, y in zip(it.count(sequence[0], sequence[1]-sequence[0]), sequence):
        if x != y:
            return x

Note: Diagnostic print()s are probably your issue.


问:
Collapsible box in Shiny App
```<code>library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

  includeCSS(path = "AdminLTE.css"), #added
  includeCSS(path = "shinydashboard.css"), #added

   # Application title
   titlePanel("Old Faithful Geyser Data"),

   # Sidebar with a slider input for number of bins
   sidebarLayout(
      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30)
      ),

      # Show a plot of the generated distribution
      mainPanel(
         box(plotOutput("distPlot"), solidHeader = T, collapsible = T, title = "collapsible box not collapsing", status = "primary")
      )
   )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

   output$distPlot <- renderPlot({
      # generate bins based on input$bins from ui.R
      x    <- faithful[, 2]
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })
}

# Run the application
shinyApp(ui = ui, server = server)
</code>```

This result is

In the above image the collpasible box is not getting collapsed when clicked on mininize button.

I have added the addtional AdminLTE.css and shinydashboard.css file in working directory, but still problem persists.

答:
To use a collapsible box within shiny only. We need to add the required javascript. Just after adding css we add this file as well.</p>

```<code>  includeCSS(path = "AdminLTE.css"), #added
  includeCSS(path = "shinydashboard.css"), #added

  #add this file and collapsible nature should work.
  includeScript(path = "app.js"), #
</code>```

Title: Collapsible box in Shiny App

Body:
library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

  includeCSS(path = "AdminLTE.css"), #added
  includeCSS(path = "shinydashboard.css"), #added

   # Application title
   titlePanel("Old Faithful Geyser Data"),

   # Sidebar with a slider input for number of bins
   sidebarLayout(
      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30)
      ),

      # Show a plot of the generated distribution
      mainPanel(
         box(plotOutput("distPlot"), solidHeader = T, collapsible = T, title = "collapsible box not collapsing", status = "primary")
      )
   )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

   output$distPlot <- renderPlot({
      # generate bins based on input$bins from ui.R
      x    <- faithful[, 2]
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })
}

# Run the application
shinyApp(ui = ui, server = server)

This result is

In the above image the collpasible box is not getting collapsed when clicked on mininize button.

I have added the addtional AdminLTE.css and shinydashboard.css file in working directory, but still problem persists.

Body:
To use a collapsible box within shiny only. We need to add the required javascript. Just after adding css we add this file as well.

  includeCSS(path = "AdminLTE.css"), #added
  includeCSS(path = "shinydashboard.css"), #added

  #add this file and collapsible nature should work.
  includeScript(path = "app.js"), #


答:
The error message says "Too much information has been written to stdout."

Remove the print() calls - stdout is (by default) where output from print() is written, so it seems the Codewars server doesn't like you printing so much.

Title: Find the missing integer in an arithmetic progression from a list in python


问:
in php, what will happen if CURLOPT_CAPATH is not set when CURLOPT_SSL_VERIFYPEER is set to true
The problem is about using curl in PHP.
Some other answers said that curl will reject any ssl connection, however, I can send https requests as normal.
curl.cainfo in php.ini is not set.
Will curl use system default ca bundle when CURLOPT_CAPATH is not set?</p>

答:
From the documentation:

```<code>CURLOPT_CAINFO

This option is by default set to the system path where
libcurl's cacert bundle is assumed to be stored, as
established at build time.
</code>```

So, if your system stores the cacert bundle in the default location, which is likely /etc/ssl/certs/, then it should find it.

Body:
From the documentation:

CURLOPT_CAINFO

This option is by default set to the system path where
libcurl's cacert bundle is assumed to be stored, as
established at build time.

So, if your system stores the cacert bundle in the default location, which is likely /etc/ssl/certs/, then it should find it.


问:
XSLT XML not showing up properly in the browser
Hello good people of StackOverflow.

I am extremely new to XSLT, so new in fact I'm trying to do my first tutorial and I can't get it to work.

I copied the code from it and without changing I put it into a file and tried to view it in Internet explorer and all i get back is plain text.  interesting if i look at the source code in the browser it shows me the HTML as if it was formatted correctly by the XSLT.  so in order to get any further with this I need to atleast be able to view the most basic XSLT example to see if I did it right.  any help would be greatly appreciated.

XML

```<code><?xml version = "1.0"?>
<?xml-stylesheet  type = "html/xsl"
              version ="1.0"
              href = "students.xsl"?>
<class>
 <student rollno = "393">
  <firstname>Dinkar</firstname>
  <lastname>Kad</lastname>
  <nickname>Dinkar</nickname>
  <marks>85</marks>
</student>
<student rollno = "493">
  <firstname>Vaneet</firstname>
  <lastname>Gupta</lastname>
  <nickname>Vinni</nickname>
  <marks>95</marks>
</student>
<student rollno = "593">
 <firstname>Jasvir</firstname>
 <lastname>Singh</lastname>
 <nickname>Jazz</nickname>
 <marks>90</marks>
</student>
</class>
</code>```

XSLT

```<code><?xml version = "1.0" encoding = "UTF-8"?>
    <xsl:stylesheet version = "2.0"
    xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
      <xsl:template match = "/">
        <html>
          <body>
            <h2>Students</h2>
            <table border = "1">
              <tr bgcolor = "#9acd32">
                <th>Roll No</th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Nick Name</th>
                <th>Marks</th>
              </tr>
              <xsl:for-each select="class/student">
                <tr>
                  <td>

                    <xsl:value-of select = "@rollno"/>
                  </td>

                  <td>
                    <xsl:value-of select = "firstname"/>
                  </td>
                  <td>
                    <xsl:value-of select = "lastname"/>
                  </td>
                  <td>
                    <xsl:value-of select = "nickname"/>
                  </td>
                  <td>
                    <xsl:value-of select = "marks"/>
                  </td>

                </tr>
              </xsl:for-each>
            </table>
           </body>
          </html>
         </xsl:template>
       </xsl:stylesheet>
</code>```

答:
Change one detail in <?xml-stylesheet (in XML file): type attribute should
be text/xsl (not html/xsl).

Body:
Hello good people of StackOverflow.

I am extremely new to XSLT, so new in fact I'm trying to do my first tutorial and I can't get it to work.

I copied the code from it and without changing I put it into a file and tried to view it in Internet explorer and all i get back is plain text.  interesting if i look at the source code in the browser it shows me the HTML as if it was formatted correctly by the XSLT.  so in order to get any further with this I need to atleast be able to view the most basic XSLT example to see if I did it right.  any help would be greatly appreciated.

XML

<?xml version = "1.0"?>
<?xml-stylesheet  type = "html/xsl"
              version ="1.0"
              href = "students.xsl"?>
<class>
 <student rollno = "393">
  <firstname>Dinkar</firstname>
  <lastname>Kad</lastname>
  <nickname>Dinkar</nickname>
  <marks>85</marks>
</student>
<student rollno = "493">
  <firstname>Vaneet</firstname>
  <lastname>Gupta</lastname>
  <nickname>Vinni</nickname>
  <marks>95</marks>
</student>
<student rollno = "593">
 <firstname>Jasvir</firstname>
 <lastname>Singh</lastname>
 <nickname>Jazz</nickname>
 <marks>90</marks>
</student>
</class>

XSLT

<?xml version = "1.0" encoding = "UTF-8"?>
    <xsl:stylesheet version = "2.0"
    xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
      <xsl:template match = "/">

Students

                Roll No
                First Name
                Last Name
                Nick Name
                Marks

              <xsl:for-each select="class/student">

                    <xsl:value-of select = "@rollno"/>

                    <xsl:value-of select = "firstname"/>

                    <xsl:value-of select = "lastname"/>

                    <xsl:value-of select = "nickname"/>

                    <xsl:value-of select = "marks"/>

              </xsl:for-each>

         </xsl:template>
       </xsl:stylesheet>


答:
The single-line display in the JavaScript console is generated at the moment you call console.log().

When you click the arrow icon later, the multiline display is generated at the time you click the arrow.

That's why you see two different things: you've changed the array sometime after the original console.log() call but before you clicked the arrow.

If you want to see the complete array contents at it existed at the time of the console.log() call, a good way to do it is to use JSON.stringify():

```<code>console.log( JSON.stringify( array, null, 4 ) );
</code>```

If you're not sure why this happened, a likely bet is that you have some asynchronous operation that modifies the array after you made the original console.log() call. For example, a common mistake is to make an ajax call to populate a global variable, and then you try to immediately use that variable in your code after the ajax call returns - but this is before the data is ready and the ajax callback is called.

In this case you shouldn't be using a global variable at all. Instead, you should handle the data returned from the server within the ajax callback itself, or in a function that you call from within that callback. Don't try to store it in a global variable, and don't assume your other code knows when the data is ready. Access the data only within the callback.

Title: Array representation

Body:
The single-line display in the JavaScript console is generated at the moment you call console.log().

When you click the arrow icon later, the multiline display is generated at the time you click the arrow.

That's why you see two different things: you've changed the array sometime after the original console.log() call but before you clicked the arrow.

If you want to see the complete array contents at it existed at the time of the console.log() call, a good way to do it is to use JSON.stringify():

console.log( JSON.stringify( array, null, 4 ) );

If you're not sure why this happened, a likely bet is that you have some asynchronous operation that modifies the array after you made the original console.log() call. For example, a common mistake is to make an ajax call to populate a global variable, and then you try to immediately use that variable in your code after the ajax call returns - but this is before the data is ready and the ajax callback is called.

In this case you shouldn't be using a global variable at all. Instead, you should handle the data returned from the server within the ajax callback itself, or in a function that you call from within that callback. Don't try to store it in a global variable, and don't assume your other code knows when the data is ready. Access the data only within the callback.


答: You could try flushing the buffer. Use a print statement like print(a, flush=True) and see if it works. Or just remove the print statements.