问:
Select Distinct from single column SQL
I have an SQLite3 Database and I need to select DISTINCT from a specific row (H981.VISITID) from the following query:

```<code>`SELECT
         H981.VISITID AS pat_no, H98.MED_REC_NO

FROM     H98_Paradigm_Encounters H98
LEFT OUTER JOIN H98_MLO_Encounters H981
  ON H98.MED_REC_NO=H981.EXTERNALID`
</code>```

The results are currently producing something like this:

```<code>|pat_no|med_rec_no|note|
|1     |4545      |Test|
|2     |4545      |Test|
|3     |4545      |Test|
|4     |4545      |    |
|1     |4545      |    |
|2     |4545      |    |
|3     |4545      |    |
|4     |4545      |Test|
</code>```

I would like the results to produce something like:

```<code>|pat_no|med_rec_no|note|
|1     |4545      |Test|
|2     |4545      |Test|
|3     |4545      |Test|
|4     |4545      |    |
</code>```

I've tried several things I've seen on here, but nothing seems to work. Any advice?

答:
You can't DISTINCT by single column, but only but a row:

```<code>select DISTINCT
</code>```

returns the list of unique rows
Thing you are looking for is called "group by" and you can't use it for so mutch columns. Why? Lets imagine that you want to get only one value of H981.VISITID, but one value of H981.VISITID refers to two values from  H98.DIAGNOSIS_2. Which of them shuld be displayed then? It's not clear.

Just check group by statement or say in comment what you want to receive and I'll help you :)

```<code>    SELECT distinct
         H981.VISITID AS pat_no, H98.MED_REC_NO

FROM     H98_Paradigm_Encounters H98
LEFT OUTER JOIN H98_MLO_Encounters H981
  ON H98.MED_REC_NO=H981.EXTERNALID`
</code>```

Will work IF all the values from med_rec_no contain the same value with certain pat_no!! Other way you'll need use group by (check this topic Select first row in each GROUP BY group?)

Title: Select Distinct from single column SQL

Body:
I have an SQLite3 Database and I need to select DISTINCT from a specific row (H981.VISITID) from the following query:

`SELECT
         H981.VISITID AS pat_no, H98.MED_REC_NO

FROM     H98_Paradigm_Encounters H98
LEFT OUTER JOIN H98_MLO_Encounters H981
  ON H98.MED_REC_NO=H981.EXTERNALID`

The results are currently producing something like this:

|pat_no|med_rec_no|note|
|1     |4545      |Test|
|2     |4545      |Test|
|3     |4545      |Test|
|4     |4545      |    |
|1     |4545      |    |
|2     |4545      |    |
|3     |4545      |    |
|4     |4545      |Test|

I would like the results to produce something like:

|pat_no|med_rec_no|note|
|1     |4545      |Test|
|2     |4545      |Test|
|3     |4545      |Test|
|4     |4545      |    |

I've tried several things I've seen on here, but nothing seems to work. Any advice?

Body:
You can't DISTINCT by single column, but only but a row:

select DISTINCT

returns the list of unique rows
Thing you are looking for is called "group by" and you can't use it for so mutch columns. Why? Lets imagine that you want to get only one value of H981.VISITID, but one value of H981.VISITID refers to two values from  H98.DIAGNOSIS_2. Which of them shuld be displayed then? It's not clear.

Just check group by statement or say in comment what you want to receive and I'll help you :)

    SELECT distinct
         H981.VISITID AS pat_no, H98.MED_REC_NO

FROM     H98_Paradigm_Encounters H98
LEFT OUTER JOIN H98_MLO_Encounters H981
  ON H98.MED_REC_NO=H981.EXTERNALID`

Will work IF all the values from med_rec_no contain the same value with certain pat_no!! Other way you'll need use group by (check this topic Select first row in each GROUP BY group?)


来源: stackexchange

问:
Why does `std::make_shared` perform two separate allocations with `-fno-rtti`?
```<code>#include <memory>
struct foo { };
int main() { std::make_shared<foo>(); }
</code>```

The asssembly generated by both g++7 and clang++5 with -fno-exceptions -Ofast for the code above:

Contains a single call to operator new if -fno-rtti is not passed.

Contains two separate calls to operator new if -fno-rtti is passed.

This can be easily verified on gcc.godbolt.org (clang++5 version):

Why is this happening? Why does disabling RTTI prevent make_shared from unifying the object and control block allocations?

答:
Naturally, std::shared_ptr will be implemented with the assumption of the compiler supporting rtti. But it can be implemented without it. See shared_ptr without RTTI? .

Taking a cue from this old GCC's libstdc++ #42019 bug. We can see that Jonathan Wakely added a fix to make this possible without RTTI.

In GCC's libstdc++, std::make_shared uses the services of std::allocated_shared which uses a non-standard constructor(as seen in the code, reproduced below).

As seen in this patch, from line 753, you can see that getting the default deleter simply requires using the services of typeid if RTTI is enabled, otherwise, it requires a separate allocation that doesn't depend on RTTI.

EDIT: 9 - May -2017: removed copyrighted code previously posted here

I haven't investigated libcxx, but I want to believe they did similar thing....

ContentLicense: CC BY-SA 3.0

Body:
#include <memory>
struct foo { };
int main() { std::make_shared<foo>(); }

The asssembly generated by both g++7 and clang++5 with -fno-exceptions -Ofast for the code above:

Contains a single call to operator new if -fno-rtti is not passed.

Contains two separate calls to operator new if -fno-rtti is passed.

This can be easily verified on gcc.godbolt.org (clang++5 version):

Why is this happening? Why does disabling RTTI prevent make_shared from unifying the object and control block allocations?


问:
Linq- How to get unmatched records based on multiple fields from two collections
I am trying to get unmatched records between two collection based on multiple fields.

```<code> public class Emp
{

    public int Id { get; set; }
    public string Name { get; set; }
    public int Amount { get; set; }

public IList<Emp> GetMasterDetails()
    {
        IList<Emp> masterList = new List<Emp>
        {
            new Emp { Id = 952491, Name = "Z005HY11", Amount = 500 },
            new Emp { Id = 952491, Name = "Z005H717", Amount = 500 },
            new Emp { Id = 1191676, Name = "Z005H717", Amount = 400 }
        };
        return masterList;
    }

    public IList<Emp> GetNonMasterDetails()
    {
        IList<Emp> nonMasterList = new List<Emp>
        {
            new Emp { Id = 952491, Name = "Z005H717", Amount = 500 },
            new Emp { Id = 1191676, Name = "Z005H717", Amount = 500 },
            new Emp { Id = 1227997, Name = "Z005HY11", Amount = 400 }
        };
        return nonMasterList;
    }

}

 Emp obj = new Emp();
        IList<Emp> masterList = obj.GetMasterDetails();
        IList<Emp> nonMasterList = obj.GetNonMasterDetails();
        var first = masterList.Where(p => !nonMasterList.Any(l => p.Id == l.Id || p.Name ==l.Name)).ToList();
        var second = nonMasterList.Where(p => !masterList.Any(l => p.Id == l.Id || p.Name == l.Name)).ToList();
</code>```

I am trying above lambda but its not working. Whats wrong I am doing here?
Thanks

答:
Your query is working good. Unmatched records where the Id or the Name are equals. Maybe you are searching for Unmatched records where the Id AND (&&) the Name are equals. Or just the ID or just the Name XOR(^).

Just replace || with && and see if that's is what you want.

Tips for your questions:

Clear your tags. This question is not about asp.net nor wpf. Is just linq, c# and boolean expressions. Also, be clear in your proposite.

Say, I want the unmatched records. Two records match when its Ids and Its names are equal.

Body:
I am trying to get unmatched records between two collection based on multiple fields.

 public class Emp
{

    public int Id { get; set; }
    public string Name { get; set; }
    public int Amount { get; set; }

public IList<Emp> GetMasterDetails()
    {
        IList<Emp> masterList = new List<Emp>
        {
            new Emp { Id = 952491, Name = "Z005HY11", Amount = 500 },
            new Emp { Id = 952491, Name = "Z005H717", Amount = 500 },
            new Emp { Id = 1191676, Name = "Z005H717", Amount = 400 }
        };
        return masterList;
    }

    public IList<Emp> GetNonMasterDetails()
    {
        IList<Emp> nonMasterList = new List<Emp>
        {
            new Emp { Id = 952491, Name = "Z005H717", Amount = 500 },
            new Emp { Id = 1191676, Name = "Z005H717", Amount = 500 },
            new Emp { Id = 1227997, Name = "Z005HY11", Amount = 400 }
        };
        return nonMasterList;
    }

}

 Emp obj = new Emp();
        IList<Emp> masterList = obj.GetMasterDetails();
        IList<Emp> nonMasterList = obj.GetNonMasterDetails();
        var first = masterList.Where(p => !nonMasterList.Any(l => p.Id == l.Id || p.Name ==l.Name)).ToList();
        var second = nonMasterList.Where(p => !masterList.Any(l => p.Id == l.Id || p.Name == l.Name)).ToList();

I am trying above lambda but its not working. Whats wrong I am doing here?
Thanks


问:
Enumerate or list all variables in a program of [your favorite language here]
A friend asked me last week how to enumerate or list all variables within a program/function/etc. for the purposes of debugging (essentially getting a snapshot of everything so you can see what variables are set to, or if they are set at all). I looked around a bit and found a relatively good way for Python:

```
#!/usr/bin/python
foo1 = "Hello world"
foo2 = "bar"
foo3 = {"1":"a",
        "2":"b"}
foo4 = "1+1"

for name in dir():
    myvalue = eval(name)
    print name, "is", type(name), "and is equal to ", myvalue
```

which will output something like:

```
__builtins__ is <type 'str'> and is equal to  <module '__builtin__' (built-in)>
__doc__ is <type 'str'> and is equal to  None
__file__ is <type 'str'> and is equal to  ./foo.py
__name__ is <type 'str'> and is equal to  __main__
foo1 is <type 'str'> and is equal to  Hello world
foo2 is <type 'str'> and is equal to  bar
foo3 is <type 'str'> and is equal to  {'1': 'a', '2': 'b'}
foo4 is <type 'str'> and is equal to  1+1
```

I have so far found a partial way in PHP (courtesy of link text) but it only lists all variables and their types, not the contents:

```
<?php
// create a few variables
$bar = 'foo';
$foo ='bar';
// create a new array object
$arrayObj = new ArrayObject(get_defined_vars());
// loop over the array object and echo variables and values
for($iterator = $arrayObj->getIterator(); $iterator->valid(); $iterator->next())
        {
        echo $iterator->key() . ' => ' . $iterator->current() . '<br />';
        }
?>
```

So I put it to you: how do you list all variables and their contents in your favorite language?

Edit by VonC: I propose this question follows the spirit of a little "code-challenge".

If you do not agree, just edit and remove the tag and the link.

答:
In java, the problem would be similar to C#, only in a more verbose mode (I know, I KNOW ;) Java is verbose... you made that clear already ;) )

You can access to object fields through Refection, but you may not access easily to method local variables. So the following is not for static analysis code, but for runtime debugging only.

```<code>package test;

import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
 *
 * @author <a href="https://stackoverflow.com/users/6309/vonc">VonC</a>
 */
public class DisplayVars
{

    private static int field1 = 1;
    private static String field2 = "~2~";
    private boolean isField = false;

    /**
     * @param args
     */
    public static void main(final String[] args)
    {
        final Field[] someFields = DisplayVars.class.getDeclaredFields();
        try
        {
            displayFields(someFields);
        } catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
    }

    /**
     * @param someFields
     * @throws IllegalAccessException
     * @throws IllegalArgumentException
     */
    @SuppressWarnings("unchecked")
    public static void displayFields(final Field[] someFields)
            throws IllegalAccessException
    {
        DisplayVars anObject = new DisplayVars();
        Object res = null;
        for (int ifields = 0; ifields < someFields.length; ifields++)
        {
            final Field aField = someFields[ifields];
            AccessController.doPrivileged(new PrivilegedAction() {
                public Object run()
                {
                    aField.setAccessible(true);
                    return null; // nothing to return
                }
            });
            res = aField.get(anObject);
            if (res != null)
            {
                System.out.println(aField.getName() + ": " + res.toString());
            } else
            {
                System.out.println(aField.getName() + ": null");
            }
        }
    }
}
</code>```

OwnerDisplayName: Kurt

ContentLicense: CC BY-SA 2.5

Body:
A friend asked me last week how to enumerate or list all variables within a program/function/etc. for the purposes of debugging (essentially getting a snapshot of everything so you can see what variables are set to, or if they are set at all). I looked around a bit and found a relatively good way for Python:

#!/usr/bin/python
foo1 = "Hello world"
foo2 = "bar"
foo3 = {"1":"a",
        "2":"b"}
foo4 = "1+1"

for name in dir():
    myvalue = eval(name)
    print name, "is", type(name), "and is equal to ", myvalue

which will output something like:

__builtins__ is <type 'str'> and is equal to  <module '__builtin__' (built-in)>
__doc__ is <type 'str'> and is equal to  None
__file__ is <type 'str'> and is equal to  ./foo.py
__name__ is <type 'str'> and is equal to  __main__
foo1 is <type 'str'> and is equal to  Hello world
foo2 is <type 'str'> and is equal to  bar
foo3 is <type 'str'> and is equal to  {'1': 'a', '2': 'b'}
foo4 is <type 'str'> and is equal to  1+1

I have so far found a partial way in PHP (courtesy of link text) but it only lists all variables and their types, not the contents:

<?php
// create a few variables
$bar = 'foo';
$foo ='bar';
// create a new array object
$arrayObj = new ArrayObject(get_defined_vars());
// loop over the array object and echo variables and values
for($iterator = $arrayObj->getIterator(); $iterator->valid(); $iterator->next())
        {
        echo $iterator->key() . ' => ' . $iterator->current() . '
';
        }
?>

So I put it to you: how do you list all variables and their contents in your favorite language?

Edit by VonC: I propose this question follows the spirit of a little "code-challenge".

If you do not agree, just edit and remove the tag and the link.

LastEditorDisplayName: VonC

Body:
In java, the problem would be similar to C#, only in a more verbose mode (I know, I KNOW ;) Java is verbose... you made that clear already ;) )

You can access to object fields through Refection, but you may not access easily to method local variables. So the following is not for static analysis code, but for runtime debugging only.

package test;

import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;

/**
 *
 * @author <a href="https://stackoverflow.com/users/6309/vonc">VonC</a>
 */
public class DisplayVars
{

    private static int field1 = 1;
    private static String field2 = "~2~";
    private boolean isField = false;

    /**
     * @param args
     */
    public static void main(final String[] args)
    {
        final Field[] someFields = DisplayVars.class.getDeclaredFields();
        try
        {
            displayFields(someFields);
        } catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }
    }

    /**
     * @param someFields
     * @throws IllegalAccessException
     * @throws IllegalArgumentException
     */
    @SuppressWarnings("unchecked")
    public static void displayFields(final Field[] someFields)
            throws IllegalAccessException
    {
        DisplayVars anObject = new DisplayVars();
        Object res = null;
        for (int ifields = 0; ifields < someFields.length; ifields++)
        {
            final Field aField = someFields[ifields];
            AccessController.doPrivileged(new PrivilegedAction() {
                public Object run()
                {
                    aField.setAccessible(true);
                    return null; // nothing to return
                }
            });
            res = aField.get(anObject);
            if (res != null)
            {
                System.out.println(aField.getName() + ": " + res.toString());
            } else
            {
                System.out.println(aField.getName() + ": null");
            }
        }
    }
}

OwnerDisplayName: VonC


问:
Why i cant see this image button on IE8 with this CSS?
So, this is the html code for the button

```<code><input type="submit" name="logueo" value="log" id="sendbu"/>
</code>```

And this is the css style

```<code>#sendbu     { width: 50px; height: 34px; font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: 12px; background: transparent url(lock.png) no-repeat center top; border: 0;   text-indent: -1000em; cursor: pointer; cursor: hand; }
</code>```

All this works on Chrome and Firefox, but in IE the button seams to dont exist. Thanks for the help.

答: @domingo why text-indent - 1000em , ie does a different calculation on negative margins , try to remove that and check once</p>

Body:
So, this is the html code for the button

<input type="submit" name="logueo" value="log" id="sendbu"/>

And this is the css style

#sendbu     { width: 50px; height: 34px; font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: 12px; background: transparent url(lock.png) no-repeat center top; border: 0;   text-indent: -1000em; cursor: pointer; cursor: hand; }

All this works on Chrome and Firefox, but in IE the button seams to dont exist. Thanks for the help.


问:
Disqus in Angular 2 application: Showing same discussion.
I have Angular 2 app in there I use ng2-awesome-disqus component.

On the page I have several items and for each item I have one discussion component :

```<code><disqus [shortname]="shortname" [identifier]="identifier"></disqus>
</code>```

shortname is same for each item

identifier is unique for each item

I would expect unique discussion for each item, but there are all the same.

答:
By default, disqus only allows a single widget per page. I think (actually, I'm sure), your module can only deal with one disqus widget. Take a look at the code of the service.

You have to fork this project and manage multiple widget by yourself or create your own component that will do that if possible.

This question might help.

Body:
I have Angular 2 app in there I use ng2-awesome-disqus component.

On the page I have several items and for each item I have one discussion component :

<disqus [shortname]="shortname" [identifier]="identifier"></disqus>

shortname is same for each item

identifier is unique for each item

I would expect unique discussion for each item, but there are all the same.


问:
How to shift iframe towards right side?
I'm currently working on the feature in which whenever a user hovers over a link, instant preview is shown below the link. Like this -

What I wanted to do is, whenever a user hovers over a link, iframe should shift towards right, just like in Google Instant preview.

```<code><div class="title" (mouseover)="overTitle()" (mouseleave)="overTitle()">
                    <a href="{{item.link}}">{{item.title}}</a>
                    <div class="box">
                        <iframe width="400px" height="400px" [src]="myUrlList[i]"></iframe>
                    </div>
                </div>
</code>```

CSS file -

```<code> .box {
      display: none;
      width: 100%;
    }

    a:hover + .box, .box:hover{
      display:block;
      position: absolute;
      z-index:100;
    }
</code>```

I tried using align="right" in div tag, but nothing happens. Also in .box class in CSS, I tried using float: right;, but nothing happens. It will be very much helpful if someone can help me. :)

答:
Here you go: http://codepen.io/ruchiccio/pen/vxVoKd

```<code>a:hover + .box, .box:hover {
      display:block;
      position: absolute;
      right:0;
      top:0;
      z-index:100;
    }
</code>```

You need to have right:0; set for the box. Also, your .box was set for a 100% width which is why the iframe didn't know where to go. You have to options: Either set the box width to 400px, which is the same as the iframe (which is what I did in my codepen):

```<code>.box {
  display: none;
  width: 400px;
}
</code>```

OR you may leave the 100% width but then add text-align:right; to the .box class. Both work.

```<code>.box {
  display: none;
  width: 100%;
  text-align: right;
}
</code>```

Title: How to shift iframe towards right side?

Body:
I'm currently working on the feature in which whenever a user hovers over a link, instant preview is shown below the link. Like this -

What I wanted to do is, whenever a user hovers over a link, iframe should shift towards right, just like in Google Instant preview.

                    {{item.title}}

CSS file -

 .box {
      display: none;
      width: 100%;
    }

    a:hover + .box, .box:hover{
      display:block;
      position: absolute;
      z-index:100;
    }

I tried using align="right" in div tag, but nothing happens. Also in .box class in CSS, I tried using float: right;, but nothing happens. It will be very much helpful if someone can help me. :)

Body:
Here you go: http://codepen.io/ruchiccio/pen/vxVoKd

a:hover + .box, .box:hover {
      display:block;
      position: absolute;
      right:0;
      top:0;
      z-index:100;
    }

You need to have right:0; set for the box. Also, your .box was set for a 100% width which is why the iframe didn't know where to go. You have to options: Either set the box width to 400px, which is the same as the iframe (which is what I did in my codepen):

.box {
  display: none;
  width: 400px;
}

OR you may leave the 100% width but then add text-align:right; to the .box class. Both work.

.box {
  display: none;
  width: 100%;
  text-align: right;
}


问:
Php Twitter Post Image
I try to post Media on Twitter with using php. I can post tweet but image is not seen. Could you help me?</p>

```<code><?php
require_once('TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
    'oauth_access_token' => "",
    'oauth_access_token_secret' => "",
    'consumer_key' => "",
    'consumer_secret' => ""
);

$media_id = '847072976486858753';
$url = "https://api.twitter.com/1.1/statuses/update.json";
$twitter = new TwitterAPIExchange($settings);
$requestMethod = 'POST';
$response = $twitter->setPostfields(
    array('status' => 'Test Tweet', 'media_ids' => $media_id)
)->buildOauth($url, $requestMethod)
    ->performRequest();
?>
</code>```

答:
You're missing the image handling portion. </p>

```<code>$url_media = "https://api.twitter.com/1.1/statuses/update_with_media.json";
$requestMethod = "POST";

$tweetmsg = $_POST['post_description'];
$twimg = $_FILES['pictureFile']['tmp_name'];

    $postfields = array(
        'status' => $tweetmsg,
        'media[]' => '@' . $twimg
    );
    try {
        $twitter = new TwitterAPIExchange($settings);
        $twitter->buildOauth($url_media, $requestMethod)
                ->setPostfields($postfields)
                ->performRequest();

        echo "You just tweeted with an image";
    } catch (Exception $ex) {
        echo $ex->getMessage();
    }
</code>```

Title: Php Twitter Post Image

Body:
I try to post Media on Twitter with using php. I can post tweet but image is not seen. Could you help me?

<?php
require_once('TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
    'oauth_access_token' => "",
    'oauth_access_token_secret' => "",
    'consumer_key' => "",
    'consumer_secret' => ""
);

$media_id = '847072976486858753';
$url = "https://api.twitter.com/1.1/statuses/update.json";
$twitter = new TwitterAPIExchange($settings);
$requestMethod = 'POST';
$response = $twitter->setPostfields(
    array('status' => 'Test Tweet', 'media_ids' => $media_id)
)->buildOauth($url, $requestMethod)
    ->performRequest();
?>

Body:
You're missing the image handling portion.

$url_media = "https://api.twitter.com/1.1/statuses/update_with_media.json";
$requestMethod = "POST";

$tweetmsg = $_POST['post_description'];
$twimg = $_FILES['pictureFile']['tmp_name'];

    $postfields = array(
        'status' => $tweetmsg,
        'media[]' => '@' . $twimg
    );
    try {
        $twitter = new TwitterAPIExchange($settings);
        $twitter->buildOauth($url_media, $requestMethod)
                ->setPostfields($postfields)
                ->performRequest();

        echo "You just tweeted with an image";
    } catch (Exception $ex) {
        echo $ex->getMessage();
    }


问:
Addition of two integer in binary representation
I would like to implement code which will add two integers by their binary representation.

For instance:

```<code>a = [1 1 1 0];
</code>```

and

```<code>b = [1 0 1 1];
</code>```

So I implemented the following algorithm:

```<code>function s=add_binary(a,b)
  m=length(a);
  s=zeros(m+1,0);
  n=length(a);
  c=0;
  for ii=n:-1:1
    d=floor((a(ii)+b(ii)+c)/2);
    s(ii)=a(ii)+b(ii)+c-2*d;
    c=d;
  end
  s(1)=c;
end
</code>```

However, it returns this as a result:

```<code>s=add_binary(a,b)

s =

     1     0     0     1
</code>```

Here, there should be an additional 1 on the left, such that it would read:

```<code>1 1 0 0 1
</code>```

Where am I making a mistake?

答:
here is my solution </p>

```<code>function s=add_binary(a,b)
m=length(a);
s=zeros(m+1,1);
n=length(a);
c=0;
for ii=n:-1:1
    d=floor((a(ii)+b(ii)+c)/2);
   s(ii+1)=a(ii)+b(ii)+c-2*d;
   c=d;
 end
s(1)=c;
s=s';

end

>> s=add_binary(a,b)

s =

     1     1     0     0     1
</code>```

Body:
I would like to implement code which will add two integers by their binary representation.

For instance:

a = [1 1 1 0];

and

b = [1 0 1 1];

So I implemented the following algorithm:

function s=add_binary(a,b)
  m=length(a);
  s=zeros(m+1,0);
  n=length(a);
  c=0;
  for ii=n:-1:1
    d=floor((a(ii)+b(ii)+c)/2);
    s(ii)=a(ii)+b(ii)+c-2*d;
    c=d;
  end
  s(1)=c;
end

However, it returns this as a result:

s=add_binary(a,b)

s =

     1     0     0     1

Here, there should be an additional 1 on the left, such that it would read:

1 1 0 0 1

Where am I making a mistake?

Body:
here is my solution

function s=add_binary(a,b)
m=length(a);
s=zeros(m+1,1);
n=length(a);
c=0;
for ii=n:-1:1
    d=floor((a(ii)+b(ii)+c)/2);
   s(ii+1)=a(ii)+b(ii)+c-2*d;
   c=d;
 end
s(1)=c;
s=s';

end

>> s=add_binary(a,b)

s =

     1     1     0     0     1


问:
How to map json and skip parent property?
I have this json string, which contains two elements each with a Number and a Status:

```<code>var jsonString = "{\"Errors\":[{\"Number\":9,\"Status\":\"BadRequest\"}, {\"Number\":3,\"Status\":\"BadConnection\"}]}";
</code>```

As you see it has a parent property called Errors.

I have prepared this model:

```<code>public class ExceptionStructure
{
    public int Number { get; set; }
    public string Status { get; set; }
}
</code>```

Using NewtonSoft.Json I would like to deserialize the json string into an array of ExceptionStructure objects, without also having to create a model for the parent property (as I don't really need it).

Can I do this (perhaps with some json attribute on the model class)?

I was hoping to do something like this to deserialize:

```<code>var exceptionArr = JsonConvert.DeserializeObject<ExceptionStructure>(jsonString);
</code>```

答:
this is may be helpful you.

```<code>    string s = "{\"Errors\":[{\"Number\":9,\"Status\":\"BadRequest\"}, {\"Number\":3,\"Status\":\"BadConnection\"}]}";
    var jobj = JObject.Parse(s);
    List<ExceptionStructure> list = jobj["Errors"].ToObject<List<ExceptionStructure>>();
</code>```

OR:

```<code>    string s = "{\"Errors\":[{\"Number\":9,\"Status\":\"BadRequest\"}, {\"Number\":3,\"Status\":\"BadConnection\"}]}";
    List<ExceptionStructure> list = JObject.Parse(s)
        .SelectToken("Errors")
        .ToObject<List<ExceptionStructure>>();
</code>```

Body:
I have this json string, which contains two elements each with a Number and a Status:

var jsonString = "{\"Errors\":[{\"Number\":9,\"Status\":\"BadRequest\"}, {\"Number\":3,\"Status\":\"BadConnection\"}]}";

As you see it has a parent property called Errors.

I have prepared this model:

public class ExceptionStructure
{
    public int Number { get; set; }
    public string Status { get; set; }
}

Using NewtonSoft.Json I would like to deserialize the json string into an array of ExceptionStructure objects, without also having to create a model for the parent property (as I don't really need it).

Can I do this (perhaps with some json attribute on the model class)?

I was hoping to do something like this to deserialize:

var exceptionArr = JsonConvert.DeserializeObject<ExceptionStructure>(jsonString);

Body:
this is may be helpful you.

    string s = "{\"Errors\":[{\"Number\":9,\"Status\":\"BadRequest\"}, {\"Number\":3,\"Status\":\"BadConnection\"}]}";
    var jobj = JObject.Parse(s);
    List<ExceptionStructure> list = jobj["Errors"].ToObject<List<ExceptionStructure>>();

OR:

    string s = "{\"Errors\":[{\"Number\":9,\"Status\":\"BadRequest\"}, {\"Number\":3,\"Status\":\"BadConnection\"}]}";
    List<ExceptionStructure> list = JObject.Parse(s)
        .SelectToken("Errors")
        .ToObject<List<ExceptionStructure>>();


问:
How to get text using vue.js 2?
I have :

```<code><span class="badge" id="total">10</span>
</code>```

If I using jquery :

```<code>$('#total').text()
</code>```

How to get it if using vue.js 2?

答:
Why does your HTML look like that?

You should never need to do what you're asking in a Vue application. With a MVVM application you'd have something like:

```<code>new Vue({
  data: {
    total: 10,
  },
})
</code>```

Then a template like:

```<code><span class="badge" id="total">{{ total }}</span>
</code>```

That way, in your VM, when you set this.total = 12 the DOM will update automatically and this.total will always return your total.

Title: How to get text using vue.js 2?

Body:
I have :

10

If I using jquery :

$('#total').text()

How to get it if using vue.js 2?

Body:
Why does your HTML look like that?

You should never need to do what you're asking in a Vue application. With a MVVM application you'd have something like:

new Vue({
  data: {
    total: 10,
  },
})

Then a template like:

<span class="badge" id="total">{{ total }}</span>

That way, in your VM, when you set this.total = 12 the DOM will update automatically and this.total will always return your total.


问:
JavaScript XMLHttpRequest with credentials to ASP.NET API
I am trying to do a post request withCredentials = true, but I get a CORS error on the console after sending the request.

This is the Controller I am trying to reach:

```<code>[RoutePrefix("Account")]
public class AccountController : ApiController;
</code>```

This is the Action I am trying to reach:

```<code>[HttpPost]
[Route("Login")]
public IHttpActionResult Login(LoginDto dto);
</code>```

I have added this line in WebApiConfig:

```<code>config.EnableCors(new EnableCorsAttribute("http://localhost", "*", "*"));
</code>```

And here is what I use to do Post Requests with Javascript

```<code>function createCORSRequest(method, url) {
    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;
    if (xhr.withCredentials != undefined) {
        xhr.open(method, url, true);
    } else if (typeof XDomainRequest != "undefined") {
        xhr = new XDomainRequest();
        xhr.open(method, url);
    } else {
        xhr = null;
    }
    return xhr;
}

function post(url, data) {
    return new Promise(
        function httpPromise (resolve, reject) {
            var request = createCORSRequest("post", url);
            if (request) {
                request.setRequestHeader('Accept', 'application/json');
                request.setRequestHeader('Content-Type', 'application/json');
                request.onloadend = function (progress) {
                    var status = request.status;
                    var result = JSON.parse(request.response || "null");
                    if (status >= 200 && status < 300) resolve(result);
                    else reject(result ? result.Message || result : result);
                };
                request.send(data);
            }
        });
}
</code>```

Below is the Error Message that appears in the console.

XMLHttpRequest cannot load http://localhost:54368/Account/Login. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

答:
You need to give specify SupportsCredentials = true in your config.EnableCors(…) call:

```<code>config.EnableCors(new EnableCorsAttribute("http://localhost", "*", "*")
{ SupportsCredentials = true });
</code>```

Body:
I am trying to do a post request withCredentials = true, but I get a CORS error on the console after sending the request.

This is the Controller I am trying to reach:

[RoutePrefix("Account")]
public class AccountController : ApiController;

This is the Action I am trying to reach:

[HttpPost]
[Route("Login")]
public IHttpActionResult Login(LoginDto dto);

I have added this line in WebApiConfig:

config.EnableCors(new EnableCorsAttribute("http://localhost", "*", "*"));

And here is what I use to do Post Requests with Javascript

function createCORSRequest(method, url) {
    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;
    if (xhr.withCredentials != undefined) {
        xhr.open(method, url, true);
    } else if (typeof XDomainRequest != "undefined") {
        xhr = new XDomainRequest();
        xhr.open(method, url);
    } else {
        xhr = null;
    }
    return xhr;
}

function post(url, data) {
    return new Promise(
        function httpPromise (resolve, reject) {
            var request = createCORSRequest("post", url);
            if (request) {
                request.setRequestHeader('Accept', 'application/json');
                request.setRequestHeader('Content-Type', 'application/json');
                request.onloadend = function (progress) {
                    var status = request.status;
                    var result = JSON.parse(request.response || "null");
                    if (status >= 200 && status < 300) resolve(result);
                    else reject(result ? result.Message || result : result);
                };
                request.send(data);
            }
        });
}

Below is the Error Message that appears in the console.

XMLHttpRequest cannot load http://localhost:54368/Account/Login. Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://localhost' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Body:
You need to give specify SupportsCredentials = true in your config.EnableCors(…) call:

config.EnableCors(new EnableCorsAttribute("http://localhost", "*", "*")
{ SupportsCredentials = true });


问:
Javascript Nested Function - Need help returning result
I am trying to create a function to return a lat/long array from the Google Maps JS API (v3). I am able to write the data out that I retrieve from the API, but I am not able to pass the data along to a variable. I am wanting to do something like this:

```<code>var latLong = getLatLong(Address);
</code>```

The function that I have created is here:

```<code>function getLatLong(loc, callback) {
  var geocoder = new google.maps.Geocoder();
  var array = new Array();

  if (geocoder) {
    geocoder.geocode({ 'address': loc }, function (results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        var latLng = results[0].geometry.location;;
        $.each(latLng, function(k, v) {
          if (k == 'va' || k == 'wa') {
            array.push(v);
          }
        });
        var ret = array;
        callback(ret);
      } else {
        console.log("Geocoding failed: " + status);
      }
    });
  }
}
</code>```

I then am assigning the function to a variable and calling it to give me the lat/long.

```<code>var geo = getLatLong('Dallas, TX', function(result) {
  return result;
});
</code>```

Unfortunately this produces an 'undefined' result. I can access the result in the function, I just can't pass it along. How can I pass the result of the function to a variable to be accessed?

答: geo is undefined because getLatLong() doesn't return anything (which means it returns undefined).</p>

Body:
I am trying to create a function to return a lat/long array from the Google Maps JS API (v3). I am able to write the data out that I retrieve from the API, but I am not able to pass the data along to a variable. I am wanting to do something like this:

var latLong = getLatLong(Address);

The function that I have created is here:

function getLatLong(loc, callback) {
  var geocoder = new google.maps.Geocoder();
  var array = new Array();

  if (geocoder) {
    geocoder.geocode({ 'address': loc }, function (results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        var latLng = results[0].geometry.location;;
        $.each(latLng, function(k, v) {
          if (k == 'va' || k == 'wa') {
            array.push(v);
          }
        });
        var ret = array;
        callback(ret);
      } else {
        console.log("Geocoding failed: " + status);
      }
    });
  }
}

I then am assigning the function to a variable and calling it to give me the lat/long.

var geo = getLatLong('Dallas, TX', function(result) {
  return result;
});

Unfortunately this produces an 'undefined' result. I can access the result in the function, I just can't pass it along. How can I pass the result of the function to a variable to be accessed?


问:
Why there is offset when my CAReplicatorLayer rotation
I am sorry to give a static pictrue, not a gif picture, so can not show the issue.

But I give the demo's code below, so you can test in your xcode.

```<code> import UIKit

class ViewController: UIViewController {

    var circelWidth:CGFloat = 0.0
    var circle_r_y:CGFloat = 316
    let apear_circle_duration:CFTimeInterval = 1.5

    let turn_ani_repeat_count:Float = 1 // times
    let turn_ani_duration:Float = 0.4 // one circle, how many time, you can change the proerty to look more detail.

    override func viewDidLoad() {
        super.viewDidLoad()

        initData()

        initUI()
    }

    func initData() {

        // 2.圆圈⭕
        if (Display.typeIsLike == .iphone6 || Display.typeIsLike == .iphone6plus) {

            self.circelWidth = 260 // must set, then animate the circel
        }else {

            self.circelWidth = 230 // must set, then animate the circel
        }
    }

    func initUI() {

        self.view.backgroundColor = UIColor.brown

        self.animateCircle()
    }

    func animateCircle() {

        let r = CAReplicatorLayer()
        r.bounds = CGRect.init(x: 0.0, y: 0.0, width: circelWidth, height: circelWidth)
        r.cornerRadius = 10.0  // 10
        r.backgroundColor = UIColor.clear.cgColor

        // var circle_r_y:CGFloat = 160.0
        circle_r_y = (UIScreen.main.bounds.size.height - 64) / 2.0 + 64

        r.position = CGPoint.init(x: self.view.bounds.width / 2.0, y: circle_r_y)

        //r.anchorPoint = CGPoint.init(x: 0.5, y: circle_r_y! / r.bounds.height)  // 锚点设置
        r.anchorPoint = CGPoint.init(x: 0.5, y: 0.5)
        self.view.layer.addSublayer(r)

        // dot
        let dot = CALayer()
        dot.bounds = CGRect(x:0.0, y :0.0, width:6.0, height:6.0)
        dot.position = CGPoint(x:100.0, y:10.0)
        dot.backgroundColor = UIColor(white:1, alpha:1.0).cgColor
        dot.cornerRadius = 3.0 // half of dot width 一半

        r.addSublayer(dot)

        let nrDots: Int = 32
        r.instanceCount = nrDots
        let angle = CGFloat(2*M_PI) / CGFloat(nrDots)
        r.instanceTransform = CATransform3DMakeRotation(angle, 0.1, 0.1, 1.0)

        let shrink = CABasicAnimation(keyPath: "transform.scale")
        shrink.fromValue = 1.0
        shrink.toValue = 1.0 // 0.5
        shrink.duration = apear_circle_duration
        shrink.repeatCount = Float.infinity

        dot.add(shrink, forKey: nil)

        r.instanceDelay = apear_circle_duration/Double(nrDots)

        dot.transform = CATransform3DMakeScale(0.1, 0.1, 0.1)

        delay(delay: apear_circle_duration) {

            let turn_key_path = "transform.rotation"
            let turn_ani = CABasicAnimation.init(keyPath: turn_key_path)
            turn_ani.isRemovedOnCompletion = false
            turn_ani.fillMode = kCAFillModeForwards
            turn_ani.toValue = M_PI*2
            turn_ani.duration = CFTimeInterval(self.turn_ani_duration)
            turn_ani.repeatCount = self.turn_ani_repeat_count
            r.add(turn_ani, forKey: turn_key_path)

            dot.transform = CATransform3DMakeScale(1, 1, 1)  // 设置回来，不然再出现会放小

        }
    }

    func delay(delay:Double, closure:@escaping ()->()){

        let when = DispatchTime.now() + delay
        DispatchQueue.main.asyncAfter(deadline: when, execute: closure)
    }

    }
</code>```

The Display.swift, it is check the device type.

```<code>import UIKit

public enum DisplayType {
case unknown
case iphone4
case iphone5
case iphone6
case iphone6plus
static let iphone7 = iphone6
static let iphone7plus = iphone6plus
}

    public final class Display {
    class var width:CGFloat { return UIScreen.main.bounds.size.width     }
    class var height:CGFloat { return UIScreen.main.bounds.size.height }
    class var maxLength:CGFloat { return max(width, height) }
    class var minLength:CGFloat { return min(width, height) }
    class var zoomed:Bool { return UIScreen.main.nativeScale >= UIScreen.main.scale }
    class var retina:Bool { return UIScreen.main.scale >= 2.0 }
    class var phone:Bool { return UIDevice.current.userInterfaceIdiom == .phone }
    class var pad:Bool { return UIDevice.current.userInterfaceIdiom == .pad }
    class var carplay:Bool { if #available(iOS 9.0, *) {
        return UIDevice.current.userInterfaceIdiom == .carPlay
    } else {
        // Fallback on earlier versions
        return false//UIDevice.current.userInterfaceIdiom == carplay
    }
    }
    class var tv:Bool { if #available(iOS 9.0, *) {
        return UIDevice.current.userInterfaceIdiom == .tv
    } else {
        // Fallback on earlier versions

        return false
        }
    }
class var typeIsLike:DisplayType {
    if phone && maxLength < 568 {
        return .iphone4
    }
    else if phone && maxLength == 568 {
        return .iphone5
    }
    else if phone && maxLength == 667 {
        return .iphone6
    }
    else if phone && maxLength == 736 {
        return .iphone6plus
    }
    return .unknown
}
}
</code>```

The issue

If you test this in your project you can find the issue, when animating, there is a little offset, this is a strange issue, because, I make sure the CAReplicatorLayer's ahchorPoint is (0.5, 0.5), but why there is a offset?

If you want to look more detail, you can change the turn_ani_duration:Float's value, you can see the offset.

答:
Probably too late but it's caused by the vector you provide to your rotate transform :
replace
    r.instanceTransform = CATransform3DMakeRotation(angle, 0.1, 0.1, 1.0)
by
    r.instanceTransform = CATransform3DMakeRotation(angle, 0, 0, 1.0)
and that's ok.

Body:
I am sorry to give a static pictrue, not a gif picture, so can not show the issue.

But I give the demo's code below, so you can test in your xcode.

 import UIKit

class ViewController: UIViewController {

    var circelWidth:CGFloat = 0.0
    var circle_r_y:CGFloat = 316
    let apear_circle_duration:CFTimeInterval = 1.5

    let turn_ani_repeat_count:Float = 1 // times
    let turn_ani_duration:Float = 0.4 // one circle, how many time, you can change the proerty to look more detail.

    override func viewDidLoad() {
        super.viewDidLoad()

        initData()

        initUI()
    }

    func initData() {

        // 2.圆圈⭕
        if (Display.typeIsLike == .iphone6 || Display.typeIsLike == .iphone6plus) {

            self.circelWidth = 260 // must set, then animate the circel
        }else {

            self.circelWidth = 230 // must set, then animate the circel
        }
    }

    func initUI() {

        self.view.backgroundColor = UIColor.brown

        self.animateCircle()
    }

    func animateCircle() {

        let r = CAReplicatorLayer()
        r.bounds = CGRect.init(x: 0.0, y: 0.0, width: circelWidth, height: circelWidth)
        r.cornerRadius = 10.0  // 10
        r.backgroundColor = UIColor.clear.cgColor

        // var circle_r_y:CGFloat = 160.0
        circle_r_y = (UIScreen.main.bounds.size.height - 64) / 2.0 + 64

        r.position = CGPoint.init(x: self.view.bounds.width / 2.0, y: circle_r_y)

        //r.anchorPoint = CGPoint.init(x: 0.5, y: circle_r_y! / r.bounds.height)  // 锚点设置
        r.anchorPoint = CGPoint.init(x: 0.5, y: 0.5)
        self.view.layer.addSublayer(r)

        // dot
        let dot = CALayer()
        dot.bounds = CGRect(x:0.0, y :0.0, width:6.0, height:6.0)
        dot.position = CGPoint(x:100.0, y:10.0)
        dot.backgroundColor = UIColor(white:1, alpha:1.0).cgColor
        dot.cornerRadius = 3.0 // half of dot width 一半

        r.addSublayer(dot)

        let nrDots: Int = 32
        r.instanceCount = nrDots
        let angle = CGFloat(2*M_PI) / CGFloat(nrDots)
        r.instanceTransform = CATransform3DMakeRotation(angle, 0.1, 0.1, 1.0)

        let shrink = CABasicAnimation(keyPath: "transform.scale")
        shrink.fromValue = 1.0
        shrink.toValue = 1.0 // 0.5
        shrink.duration = apear_circle_duration
        shrink.repeatCount = Float.infinity

        dot.add(shrink, forKey: nil)

        r.instanceDelay = apear_circle_duration/Double(nrDots)

        dot.transform = CATransform3DMakeScale(0.1, 0.1, 0.1)

        delay(delay: apear_circle_duration) {

            let turn_key_path = "transform.rotation"
            let turn_ani = CABasicAnimation.init(keyPath: turn_key_path)
            turn_ani.isRemovedOnCompletion = false
            turn_ani.fillMode = kCAFillModeForwards
            turn_ani.toValue = M_PI*2
            turn_ani.duration = CFTimeInterval(self.turn_ani_duration)
            turn_ani.repeatCount = self.turn_ani_repeat_count
            r.add(turn_ani, forKey: turn_key_path)

            dot.transform = CATransform3DMakeScale(1, 1, 1)  // 设置回来，不然再出现会放小

        }
    }

    func delay(delay:Double, closure:@escaping ()->()){

        let when = DispatchTime.now() + delay
        DispatchQueue.main.asyncAfter(deadline: when, execute: closure)
    }

    }

The Display.swift, it is check the device type.

import UIKit

public enum DisplayType {
case unknown
case iphone4
case iphone5
case iphone6
case iphone6plus
static let iphone7 = iphone6
static let iphone7plus = iphone6plus
}

    public final class Display {
    class var width:CGFloat { return UIScreen.main.bounds.size.width     }
    class var height:CGFloat { return UIScreen.main.bounds.size.height }
    class var maxLength:CGFloat { return max(width, height) }
    class var minLength:CGFloat { return min(width, height) }
    class var zoomed:Bool { return UIScreen.main.nativeScale >= UIScreen.main.scale }
    class var retina:Bool { return UIScreen.main.scale >= 2.0 }
    class var phone:Bool { return UIDevice.current.userInterfaceIdiom == .phone }
    class var pad:Bool { return UIDevice.current.userInterfaceIdiom == .pad }
    class var carplay:Bool { if #available(iOS 9.0, *) {
        return UIDevice.current.userInterfaceIdiom == .carPlay
    } else {
        // Fallback on earlier versions
        return false//UIDevice.current.userInterfaceIdiom == carplay
    }
    }
    class var tv:Bool { if #available(iOS 9.0, *) {
        return UIDevice.current.userInterfaceIdiom == .tv
    } else {
        // Fallback on earlier versions

        return false
        }
    }
class var typeIsLike:DisplayType {
    if phone && maxLength < 568 {
        return .iphone4
    }
    else if phone && maxLength == 568 {
        return .iphone5
    }
    else if phone && maxLength == 667 {
        return .iphone6
    }
    else if phone && maxLength == 736 {
        return .iphone6plus
    }
    return .unknown
}
}

The issue

If you test this in your project you can find the issue, when animating, there is a little offset, this is a strange issue, because, I make sure the CAReplicatorLayer's ahchorPoint is (0.5, 0.5), but why there is a offset?

If you want to look more detail, you can change the turn_ani_duration:Float's value, you can see the offset.


问:
Java Android - finding file extension
So I'm trying to get the extension from a file so that I can compare it to a string to see if the extension matches the extension I want to find. However, at the moment I think I am able to get the extension but then comparing it with the one I want to find is causing my app to crash and close immediately. Also, I want it to be able to cope with files that don't have extensions and just pass them off as files that don't match the wanted file extension. Below is the code snippet that performs this, hopefully someone can explain to me what I'm doing wrong here.

```<code>File directory =  getFilesDir();
File[] listOfFiles = directory.listFiles();
String[] fileArray;
ListView fileList = (ListView) findViewById(R.id.fileList);
fileArray = new String[listOfFiles.length];
for (int i = 0; i < listOfFiles.length; ++i){
    String extension = MimeTypeMap.getFileExtensionFromUrl(listOfFiles[i].getAbsolutePath());
    if (extension.equals("txt")) {
        fileArray[i] = listOfFiles[i].getName();
    }
</code>```

P.S: I'm new to Java and Android Development so please be nice to me. :)

EDIT:

Okay, I'm being asked to post my errors, I don't really know how to post them in a nice way but this is the best I can do.

03-29 15:39:32.437 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.479 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.522 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.571 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.618 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.671 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.724 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.766 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.809 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.884 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.887 7671-7671/? W/System: ClassLoader referenced unknown path: /data/app/com.removedforprivacy.appname-1/lib/arm64
03-29 15:39:32.894 7671-7671/? I/InstantRun: Starting Instant Run Server for com.removedforprivacy.appname
03-29 15:39:33.061 7671-7671/? I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
03-29 15:39:33.276 7671-7671/? I/HwSecImmHelper: mSecurityInputMethodService is null
03-29 15:39:33.349 7671-7727/? I/OpenGLRenderer: Initialized EGL, version 1.4
03-29 15:39:33.396 7671-7671/? W/art: Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
03-29 15:39:34.694 7671-7677/? I/art: Ignoring second debugger -- accepting and dropping

The above is the log from when the app is started. This is before the problem area is loaded. The below is when I press the button that triggers the running of the problem area.

03-29 15:42:50.550 10762-10762/? I/art: Late-enabling -Xcheck:jni
03-29 15:42:50.654 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.808 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.851 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.895 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.953 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.008 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.072 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.151 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.197 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.241 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.315 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.318 10762-10762/com.removedforprivacy.appname W/System: ClassLoader referenced unknown path: /data/app/com.removedforprivacy.appname-1/lib/arm64
03-29 15:42:51.326 10762-10762/com.removedforprivacy.appname I/InstantRun: Starting Instant Run Server for com.removedforprivacy.appname

One last thing, when I press the button, there is another bit of logs shown which I think is different to the above but it very quickly disappears so I can't copy it in. Hope that helps.

答:
Personally, I prefer to use FilenameUtils.getExtension(file_name) provided by Apache Commons IO. You can add this line to your app's build.gradle:

```<code>dependencies {
    compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
}
</code>```

And then use it in your code:

```<code>for (int i = 0; i < listOfFiles.length; i++){
    String extension = FilenameUtils.getExtension(listOfFiles[i].getAbsolutePath());
    if (extension.equals("txt")) {
        fileArray[i] = listOfFiles[i].getName();
    }
}
</code>```

Title: Java Android - finding file extension

Body:
So I'm trying to get the extension from a file so that I can compare it to a string to see if the extension matches the extension I want to find. However, at the moment I think I am able to get the extension but then comparing it with the one I want to find is causing my app to crash and close immediately. Also, I want it to be able to cope with files that don't have extensions and just pass them off as files that don't match the wanted file extension. Below is the code snippet that performs this, hopefully someone can explain to me what I'm doing wrong here.

File directory =  getFilesDir();
File[] listOfFiles = directory.listFiles();
String[] fileArray;
ListView fileList = (ListView) findViewById(R.id.fileList);
fileArray = new String[listOfFiles.length];
for (int i = 0; i < listOfFiles.length; ++i){
    String extension = MimeTypeMap.getFileExtensionFromUrl(listOfFiles[i].getAbsolutePath());
    if (extension.equals("txt")) {
        fileArray[i] = listOfFiles[i].getName();
    }

P.S: I'm new to Java and Android Development so please be nice to me. :)

EDIT:

Okay, I'm being asked to post my errors, I don't really know how to post them in a nice way but this is the best I can do.

03-29 15:39:32.437 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.479 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.522 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.571 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.618 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.671 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.724 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.766 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.809 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.884 7671-7671/? W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
03-29 15:39:32.887 7671-7671/? W/System: ClassLoader referenced unknown path: /data/app/com.removedforprivacy.appname-1/lib/arm64
03-29 15:39:32.894 7671-7671/? I/InstantRun: Starting Instant Run Server for com.removedforprivacy.appname
03-29 15:39:33.061 7671-7671/? I/HwCust: Constructor found for class android.app.HwCustHwWallpaperManagerImpl
03-29 15:39:33.276 7671-7671/? I/HwSecImmHelper: mSecurityInputMethodService is null
03-29 15:39:33.349 7671-7727/? I/OpenGLRenderer: Initialized EGL, version 1.4
03-29 15:39:33.396 7671-7671/? W/art: Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
03-29 15:39:34.694 7671-7677/? I/art: Ignoring second debugger -- accepting and dropping

The above is the log from when the app is started. This is before the problem area is loaded. The below is when I press the button that triggers the running of the problem area.

03-29 15:42:50.550 10762-10762/? I/art: Late-enabling -Xcheck:jni
03-29 15:42:50.654 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.808 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.851 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.895 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:50.953 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.008 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.072 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.151 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.197 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.241 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.315 10762-10762/com.removedforprivacy.appname W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.removedforprivacy.appname-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.removedforprivacy.appname-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
03-29 15:42:51.318 10762-10762/com.removedforprivacy.appname W/System: ClassLoader referenced unknown path: /data/app/com.removedforprivacy.appname-1/lib/arm64
03-29 15:42:51.326 10762-10762/com.removedforprivacy.appname I/InstantRun: Starting Instant Run Server for com.removedforprivacy.appname

One last thing, when I press the button, there is another bit of logs shown which I think is different to the above but it very quickly disappears so I can't copy it in. Hope that helps.

Body:
Personally, I prefer to use FilenameUtils.getExtension(file_name) provided by Apache Commons IO. You can add this line to your app's build.gradle:

dependencies {
    compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
}

And then use it in your code:

for (int i = 0; i < listOfFiles.length; i++){
    String extension = FilenameUtils.getExtension(listOfFiles[i].getAbsolutePath());
    if (extension.equals("txt")) {
        fileArray[i] = listOfFiles[i].getName();
    }
}


问:
How to add Web Service Response into NSDictionary in objective C, IOS
I am getting response form asp.net web services and when I try to convert that NSData response in NSDictionary format that time it stores nil. Then how to convert it into NSDictionary?
Thanks in Advance

Here is my code:

```<code>  -(void)jsonresponse:(NSMutableString *)json
   {
    NSData *data=[json dataUsingEncoding:NSUTF8StringEncoding];

NSError *error=nil;

NSDictionary *json1=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

tableArray= [NSMutableArray array];
   // menuArray=[NSMutableArray array];

for (NSDictionary *dic in [json1 objectForKey:@"Table"])
{
    [tableArray addObject:@{@"StudentId" : [dic objectForKey:@"StudentId"],
                         @"UserID" : [dic objectForKey:@"UserID"],
                         @"StudentName" : [dic objectForKey:@"StudentName"],
                         @"UserTypeName" : [dic objectForKey:@"UserTypeName"],
                         @"Path" : [dic objectForKey:@"Path"],
                         @"UnreadMessageCount" : [dic objectForKey:@"UnreadMessageCount"],
                         @"LastMessageTime" : [dic objectForKey:@"LastMessageTime"],
                         @"Image" : [dic objectForKey:@"Image"]}];

}

NSLog(@"table Array is==%@",tableArray);

for (NSDictionary *dic in [json1 objectForKey:@"Table1"])
{
    [menuArray addObject:@{@"MenuName":[dic objectForKey:@"MenuName"],
                           @"MenuName1" : [dic objectForKey:@"UserID"],
                           @"Icon" : [dic objectForKey:@"Icon"],
                           @"URL" : [dic objectForKey:@"URL"],
                           @"UserTypeConst" : [dic objectForKey:@"Path"]}];
}
 //   [self performSegueWithIdentifier:@"loginbutton" sender:nil];

NSLog(@"Menu Array is==%@",menuArray);
}
</code>```

Here is my response

```<code>{
"Table": [{
    "StudentId": "755",
    "UserID": "1618",
    "StudentName": "VRITEE SHAH",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "103",
    "LastMessageTime": "12/02/2016 16:52:30",
    "Image": ""
}, {
    "StudentId": "2629",
    "UserID": "5380",
    "StudentName": "NILESH PINGALE",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "68",
    "LastMessageTime": "12/05/2016 14:41:51",
    "Image": ""
}, {
    "StudentId": "2630",
    "UserID": "5386",
    "StudentName": "MEGAN ABRAHANM",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "190",
    "LastMessageTime": "12/07/2016 17:04:06",
    "Image": ""
}, {
    "StudentId": "2828",
    "UserID": "5784",
    "StudentName": "VAIBHAVI JOSHI",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "21",
    "LastMessageTime": "12/05/2016 14:41:51",
    "Image": ""
}, {
    "StudentId": "2866",
    "UserID": "5856",
    "StudentName": "ISHITA BACHANI",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "2",
    "LastMessageTime": "10/30/2016 10:52:48",
    "Image": ""
}],
"Table1": [{
    "MenuName": "Student Info",
    "MenuName1": "Profile ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/student_info.png ",
    "URL": "StudentProfile ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Student Info",
    "MenuName1": "Calendar ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/calender.png ",
    "URL": "Calendar ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Student Info",
    "MenuName1": "Time Table ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/timetable.png ",
    "URL": "TimeTable ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Student Info",
    "MenuName1": "View Attendance ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/view_attendance.png ",
    "URL": "ViewAttendance ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Transportation",
    "MenuName1": "Map View ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/map_view.png ",
    "URL": "MapView ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Transportation",
    "MenuName1": "Alerts & Notification ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/alerts&notification.png ",
    "URL": "AlertsNotification ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Transportation",
    "MenuName1": "Transportation Desk ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/transportation_desk.png ",
    "URL": "TransportationDesk ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Notification ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/notification.png ",
    "URL": "Notification ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Principal’s Desk ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/principal_desk.png ",
    "URL": "PrincipalDesk ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Digital Diary ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/digital_diary.png ",
    "URL": "DigitalDiary ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Assignment ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/assignment.png ",
    "URL": "Assignment ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Payment Info",
    "MenuName1": "View Bill ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/view_bill.png ",
    "URL": "ViewBill ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Payment Info",
    "MenuName1": "Pay Bill ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/pay_bill.png ",
    "URL": "PayBill ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Payment Info",
    "MenuName1": "Online Payment History ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/onlinepayment_history.png ",
    "URL": "OnlinePaymentHistory ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Change Password",
    "MenuName1": "Change Password ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/change_password.png ",
    "URL": "ChangePassword ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Delete User",
    "MenuName1": "Delete User ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/delete.png ",
    "URL": "DeleteUser ",
    "UserTypeConst": "PAR"
}]
</code>```

}

答:
yes i got answer check my code

```<code>NSData *data=[json dataUsingEncoding:NSUTF8StringEncoding];

NSError *error=nil;

NSDictionary *json1=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

tableArray= [NSMutableArray array];

menuArray=[NSMutableArray array];

for (NSDictionary *dic in [json1 objectForKey:@"Table"])
{
    [tableArray addObject:@{@"StudentId" : [dic objectForKey:@"StudentId"],
                         @"UserID" : [dic objectForKey:@"UserID"],
                         @"StudentName" : [dic objectForKey:@"StudentName"],
                         @"UserTypeName" : [dic objectForKey:@"UserTypeName"],
                         @"Path" : [dic objectForKey:@"Path"],
                         @"UnreadMessageCount" : [dic objectForKey:@"UnreadMessageCount"],
                         @"LastMessageTime" : [dic objectForKey:@"LastMessageTime"],
                         @"Image" : [dic objectForKey:@"Image"]}];

}

NSLog(@"table Array is==%@",tableArray);

for (NSDictionary *dic in [json1 objectForKey:@"Table1"])
{
    [menuArray addObject:@{@"MenuName":[dic objectForKey:@"MenuName"],
                           @"MenuName1" : [dic objectForKey:@"MenuName1"],
                           @"Icon" : [dic objectForKey:@"Icon"],
                           @"URL" : [dic objectForKey:@"URL"],
                           @"UserTypeConst" : [dic objectForKey:@"UserTypeConst"]}];

}
 //   [self performSegueWithIdentifier:@"loginbutton" sender:nil];
NSLog(@"menu count=%lu",(unsigned long)menuArray.count);
NSLog(@"Menu Array is==%@",menuArray);
</code>```

after removed space in web response.

Body:
I am getting response form asp.net web services and when I try to convert that NSData response in NSDictionary format that time it stores nil. Then how to convert it into NSDictionary?
Thanks in Advance

Here is my code:

  -(void)jsonresponse:(NSMutableString *)json
   {
    NSData *data=[json dataUsingEncoding:NSUTF8StringEncoding];

NSError *error=nil;

NSDictionary *json1=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

tableArray= [NSMutableArray array];
   // menuArray=[NSMutableArray array];

for (NSDictionary *dic in [json1 objectForKey:@"Table"])
{
    [tableArray addObject:@{@"StudentId" : [dic objectForKey:@"StudentId"],
                         @"UserID" : [dic objectForKey:@"UserID"],
                         @"StudentName" : [dic objectForKey:@"StudentName"],
                         @"UserTypeName" : [dic objectForKey:@"UserTypeName"],
                         @"Path" : [dic objectForKey:@"Path"],
                         @"UnreadMessageCount" : [dic objectForKey:@"UnreadMessageCount"],
                         @"LastMessageTime" : [dic objectForKey:@"LastMessageTime"],
                         @"Image" : [dic objectForKey:@"Image"]}];

}

NSLog(@"table Array is==%@",tableArray);

for (NSDictionary *dic in [json1 objectForKey:@"Table1"])
{
    [menuArray addObject:@{@"MenuName":[dic objectForKey:@"MenuName"],
                           @"MenuName1" : [dic objectForKey:@"UserID"],
                           @"Icon" : [dic objectForKey:@"Icon"],
                           @"URL" : [dic objectForKey:@"URL"],
                           @"UserTypeConst" : [dic objectForKey:@"Path"]}];
}
 //   [self performSegueWithIdentifier:@"loginbutton" sender:nil];

NSLog(@"Menu Array is==%@",menuArray);
}

Here is my response

{
"Table": [{
    "StudentId": "755",
    "UserID": "1618",
    "StudentName": "VRITEE SHAH",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "103",
    "LastMessageTime": "12/02/2016 16:52:30",
    "Image": ""
}, {
    "StudentId": "2629",
    "UserID": "5380",
    "StudentName": "NILESH PINGALE",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "68",
    "LastMessageTime": "12/05/2016 14:41:51",
    "Image": ""
}, {
    "StudentId": "2630",
    "UserID": "5386",
    "StudentName": "MEGAN ABRAHANM",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "190",
    "LastMessageTime": "12/07/2016 17:04:06",
    "Image": ""
}, {
    "StudentId": "2828",
    "UserID": "5784",
    "StudentName": "VAIBHAVI JOSHI",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "21",
    "LastMessageTime": "12/05/2016 14:41:51",
    "Image": ""
}, {
    "StudentId": "2866",
    "UserID": "5856",
    "StudentName": "ISHITA BACHANI",
    "UserTypeName": "Student",
    "Path": "",
    "UnreadMessageCount": "2",
    "LastMessageTime": "10/30/2016 10:52:48",
    "Image": ""
}],
"Table1": [{
    "MenuName": "Student Info",
    "MenuName1": "Profile ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/student_info.png ",
    "URL": "StudentProfile ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Student Info",
    "MenuName1": "Calendar ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/calender.png ",
    "URL": "Calendar ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Student Info",
    "MenuName1": "Time Table ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/timetable.png ",
    "URL": "TimeTable ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Student Info",
    "MenuName1": "View Attendance ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/view_attendance.png ",
    "URL": "ViewAttendance ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Transportation",
    "MenuName1": "Map View ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/map_view.png ",
    "URL": "MapView ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Transportation",
    "MenuName1": "Alerts & Notification ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/alerts&notification.png ",
    "URL": "AlertsNotification ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Transportation",
    "MenuName1": "Transportation Desk ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/transportation_desk.png ",
    "URL": "TransportationDesk ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Notification ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/notification.png ",
    "URL": "Notification ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Principal’s Desk ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/principal_desk.png ",
    "URL": "PrincipalDesk ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Digital Diary ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/digital_diary.png ",
    "URL": "DigitalDiary ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Notification/Alerts",
    "MenuName1": "Assignment ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/assignment.png ",
    "URL": "Assignment ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Payment Info",
    "MenuName1": "View Bill ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/view_bill.png ",
    "URL": "ViewBill ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Payment Info",
    "MenuName1": "Pay Bill ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/pay_bill.png ",
    "URL": "PayBill ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Payment Info",
    "MenuName1": "Online Payment History ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/onlinepayment_history.png ",
    "URL": "OnlinePaymentHistory ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Change Password",
    "MenuName1": "Change Password ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/change_password.png ",
    "URL": "ChangePassword ",
    "UserTypeConst": "PAR"
}, {
    "MenuName": "Delete User",
    "MenuName1": "Delete User ",
    "Icon": "http://192.168.0.125:85/Images/NavigationIcon/delete.png ",
    "URL": "DeleteUser ",
    "UserTypeConst": "PAR"
}]

}

Body:
yes i got answer check my code

NSData *data=[json dataUsingEncoding:NSUTF8StringEncoding];

NSError *error=nil;

NSDictionary *json1=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

tableArray= [NSMutableArray array];

menuArray=[NSMutableArray array];

for (NSDictionary *dic in [json1 objectForKey:@"Table"])
{
    [tableArray addObject:@{@"StudentId" : [dic objectForKey:@"StudentId"],
                         @"UserID" : [dic objectForKey:@"UserID"],
                         @"StudentName" : [dic objectForKey:@"StudentName"],
                         @"UserTypeName" : [dic objectForKey:@"UserTypeName"],
                         @"Path" : [dic objectForKey:@"Path"],
                         @"UnreadMessageCount" : [dic objectForKey:@"UnreadMessageCount"],
                         @"LastMessageTime" : [dic objectForKey:@"LastMessageTime"],
                         @"Image" : [dic objectForKey:@"Image"]}];

}

NSLog(@"table Array is==%@",tableArray);

for (NSDictionary *dic in [json1 objectForKey:@"Table1"])
{
    [menuArray addObject:@{@"MenuName":[dic objectForKey:@"MenuName"],
                           @"MenuName1" : [dic objectForKey:@"MenuName1"],
                           @"Icon" : [dic objectForKey:@"Icon"],
                           @"URL" : [dic objectForKey:@"URL"],
                           @"UserTypeConst" : [dic objectForKey:@"UserTypeConst"]}];

}
 //   [self performSegueWithIdentifier:@"loginbutton" sender:nil];
NSLog(@"menu count=%lu",(unsigned long)menuArray.count);
NSLog(@"Menu Array is==%@",menuArray);

after removed space in web response.